提交表格我得到了
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();
});
我从localhost开始:8888 / mymapping / myformtest / 123 - &gt;工作良好 我点击按钮,浏览器转到localhost:8888 / mymapping / myformtest / 123 - &gt;
405 (Method Not Allowed) 'POST' not supported
任何想法为什么?
答案 0 :(得分:0)