Spring mvc 请求方法';邮政';不支持405

Spring mvc 请求方法';邮政';不支持405,spring-mvc,thymeleaf,Spring Mvc,Thymeleaf,在提交表格时,我得到一个 Response Status: 405 (Method Not Allowed) Cause: org.springframework.web.HttpRequestMethodNotSupportedException Request method 'POST' not supported 我不知道为什么 控制器: RequestMapping("/mymapping") public class MyController extends AbstractC

在提交表格时,我得到一个

 Response Status: 405 (Method Not Allowed) Cause:
 org.springframework.web.HttpRequestMethodNotSupportedException Request
 method 'POST' not supported
我不知道为什么

控制器:

RequestMapping("/mymapping")
public class MyController extends AbstractController {

@RequestMapping(value = "/myformtest/{taskId}", method = {RequestMethod.GET})
public String functionone(@PathVariable("taskId") String taskId, Model model, Locale locale, Authentication authentication) {
 dosomething...
}

    @RequestMapping(value = "/myformtest/{taskId} ", method = {RequestMethod.POST})
public String functiontwo(@PathParam("taskId") String taskId,
        @ModelAttribute("myObject") MyObject myObject,
        @ModelAttribute("taskAction") String taskAction,
        Model model, Locale locale, Authentication authentication) {
 dosomething...
}
}

<form id="myform" action="#" class="form-horizontal" data-toggle="validator" method="POST" role="form"  th:object="${myObject}">

</form>

<button type="button" value="FORWARD" class="btn btn-success submitBtn" th:text="#{mytext}"></button>    

$('.submitBtn').click(function() {
  $('#taskAction').val($(this).attr("value"));
  $("#myform").attr('action', $("#taskId").val());
  $("#myform").submit();
});

知道为什么吗?

我找到了漏洞。post methode的RequestMapping中有一个空格。

可以,但不要更正问题。这样的话,ppl就更难理解了。这段代码的建议。为此,应使用
@GetMapping(“/myformtest/{taskId}”)
@PostMapping(“/myformtest/{taskId}”)
405 (Method Not Allowed) 'POST' not supported