为什么不支持SpringMVC请求方法'GET'?

我尝试@RequestMapping(value = "/test", method = RequestMethod.POST)但是是错误的

代码是

 @Controller

public class HelloWordController {

private Logger logger = LoggerFactory.getLogger(HelloWordController.class);

@RequestMapping(value = "/test", method = RequestMethod.POST)

public String welcome() {

logger.info("Spring params is welcome");

return "/WEB-INF/jsp/welcome";

}

}

web.xml是

<servlet>

<description>This is Spring MVC DispatcherServlet</description>

<servlet-name>SpringMVC DispatchServlet</servlet-name>

<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>

<init-param>

<description>SpringContext</description>

<param-name>contextConfigLocation</param-name>

<param-value>classpath*:springmvc.xml</param-value>

</init-param>

<load-on-startup>1</load-on-startup>

<servlet-mapping>

<servlet-name>SpringMVC DispatchServlet</servlet-name>

<url-pattern>/</url-pattern>

和springmvc.xml是

index.jsp是

<form action="<%=request.getContextPath() %>/test" method="post">

<input type="submit" value="submit">

</form>

我输入提交botton浏览器是错误的

HTTP状态405-请求方法’GET’不支持类型状态报告

消息不支持请求方法“ GET”

描述所请求的资源不允许使用指定的HTTP方法(不支持请求方法’GET’)。

回答:

更改

@RequestMapping(value = "/test", method = RequestMethod.POST)

@RequestMapping(value = "/test", method = RequestMethod.GET)

以上是 为什么不支持SpringMVC请求方法&#39;GET&#39;? 的全部内容, 来源链接: utcz.com/qa/409678.html

回到顶部