我有一个基于Spring Web模型 - 视图 - 控制器(MVC)框架的项目。在WebLogic Server版本上部署的Spring Web模型 - 视图 - 控制器(MVC)框架的版本为3.2.8:12.1.2.0.0
我在JSP中有这段代码
<button id="deleteImageButtonId165850" class="btn btn-primary" type="submit" >Delete Image</button>
<script>
$('#deleteImageButtonId165850').click(function(){$('#serviceFormId').attr('action', 'http://127.0.0.1:7001/devices/newdesign/manage/application/service/image/del/165850');
$('#serviceFormId').attr('method', 'delete');});
</script>
和我的控制器
@RequestMapping(value = { "/newdesign/manage/application/service/image/del/{imageId}",
"/newdesign/manage/application/service/image/del/{imageId}/" }, method = { RequestMethod.DELETE })
public String deleteServiceImage(@ModelAttribute("serviceForm") ServiceForm serviceForm, @PathVariable Long imageId,
HttpServletRequest request, Model model) throws Exception {
..
}
但是当我点击按钮时,我得到了一个
Request method 'GET' not supported
答案 0 :(得分:0)
测试以下代码
@RequestMapping(value = { "/newdesign/manage/application/service/image/del/{imageId}",
"/newdesign/manage/application/service/image/del/{imageId}/" }, method = { RequestMethod.POST })
public String deleteServiceImage(@ModelAttribute("serviceForm") ServiceForm serviceForm, @PathVariable Long imageId,
HttpServletRequest request, Model model) throws Exception {
..
}
答案 1 :(得分:0)
HTML表单只支持GET和POST。 您必须在JavaScript中执行DELETE。