Spring:状态405。不支持请求方法'POST'
Spring: Status 405. Request method 'POST' not supported
我从一个动作发送到
<form name='recoverForm' action="<c:url value='recover'/>" method='POST'>
spring:
@Controller
@RequestMapping(value = "recover")
public class RecoverController {
@RequestMapping(method = RequestMethod.GET)
public String recoverPage(Map<String, Object> model) {
return "recover"; //this works
}
@RequestMapping(method = RequestMethod.POST)
public String recover(Map<String, Object> model) {
System.out.println("_____________recover in action");
return "home"; //error 405
}
但我收到错误 405 - 不支持请求方法 'POST'。
这是为什么?我发送 post request
并且控制器有一个 post 方法不是吗?
在 Spring-security.xml <csrf />
中:Spring 安全跨站请求伪造 (CSRF) 保护阻止了它。
通过 POST 请求需要令牌和表格。
在表格中添加以下内容:
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
我从一个动作发送到
<form name='recoverForm' action="<c:url value='recover'/>" method='POST'>
spring:
@Controller
@RequestMapping(value = "recover")
public class RecoverController {
@RequestMapping(method = RequestMethod.GET)
public String recoverPage(Map<String, Object> model) {
return "recover"; //this works
}
@RequestMapping(method = RequestMethod.POST)
public String recover(Map<String, Object> model) {
System.out.println("_____________recover in action");
return "home"; //error 405
}
但我收到错误 405 - 不支持请求方法 'POST'。
这是为什么?我发送 post request
并且控制器有一个 post 方法不是吗?
在 Spring-security.xml <csrf />
中:Spring 安全跨站请求伪造 (CSRF) 保护阻止了它。
通过 POST 请求需要令牌和表格。
在表格中添加以下内容:
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>