我想@RequestMapping(value = "/test", method = RequestMethod.POST)
但錯誤爲什麼不支持SpringMVC請求方法'GET'?
守則
@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>
我輸入提交鈕布勞爾是錯誤
個HTTP狀態405 - 請求方法「GET」 不支持的類型的狀態報告
消息請求方法「GET」不 支持
描述指定的HTTP方法 不允許針對所請求的 資源(請求方法'GET'不支持 )。
你的歡迎()方法查看日誌信息? – naikus 2010-07-26 11:28:01
不,我可以看到日誌 – EdwardLau 2010-07-26 13:18:57
我還不清楚如何解決這個問題,這裏沒有好的答案。沒有人解釋爲什麼我們不能做RequestMethod.POST。有人可以跟進嗎?我不明白任何評論。 – 2016-10-17 20:38:22