当我点击提交按钮时,我试图在jsp页面中使用操作显示页面。但我遇到了一个问题。当我使用method =" get"它的作品和网址显示我使用表单发送的参数。但问题是当我使用method =" post"网址正确但显示错误页面。
以下是代码:
<form id="forgotpassForm" action="anonymous/forgot_password"
method="post">
这是错误:
17:27:24.305 WARN --- [http-nio-8080-exec-4] org.springframework.web.servlet.PageNotFound : Request method 'POST' not supported
感谢您的回复。
答案 0 :(得分:0)
您是否为POST添加了处理程序?
@RequestMapping(method = RequestMethod.POST)
答案 1 :(得分:0)
如果你使用的是春天&gt; 4.3您可以在控制器方法中使用@PostMapping
来处理帖子表格
@PostMapping(value = "/anonymous/forgot_password")
public ResponseEntity<?> forgotPassword() {
...
}
答案 2 :(得分:0)
@RequestMapping(value = "forgot_password", method=
RequestMethod.POST)
public ResponseEntity<ServiceResponse>
changePassword(@RequestParam("email") String email) {
anonService.requestForgotPassword(email);
return new ResponseEntity<>(
ServiceResponse.getServiceResponse("Forgot password
request processed successfully. " +
"An email has been sent to the provided email with
password reset link"),
HttpStatus.OK
);
}