首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >删除Spring MVC中的表述性状态转移

删除Spring MVC中的表述性状态转移
EN

Stack Overflow用户
提问于 2017-01-30 20:14:32
回答 2查看 34关注 0票数 0

我有一个基于Spring Web模型-视图-控制器(MVC)框架的项目。Spring Web model-view-controller (MVC)框架的版本是部署在WebLogic服务器上的3.2.8版本: 12.1.2.0.0

我的JSP中有这段代码

代码语言:javascript
复制
<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>

和我的控制器

代码语言:javascript
复制
@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 {
..
}

但是当我点击按钮时,我得到了一个

代码语言:javascript
复制
Request method 'GET' not supported
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-01-30 20:26:58

HTML表单只支持GET和POST。您必须在JavaScript中进行删除。

票数 0
EN

Stack Overflow用户

发布于 2017-01-30 20:26:27

测试以下代码

代码语言:javascript
复制
@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 {
..
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41935698

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档