springMVC将post请求转为delete/put请求-成都快上网建站

springMVC将post请求转为delete/put请求

需要在web.xml文件配置


HiddenHttpMethodFilter
org.springframework.web.filter.HiddenHttpMethodFilter

为明山等地区用户提供了全套网页设计制作服务,及明山网站建设行业解决方案。主营业务为成都网站建设、网站建设、明山网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!


HiddenHttpMethodFilter
/*

在页面上使用隐藏的from提交


或者ajax请求提交
var url = ""+"/"+pid+".do";
$.ajax({
type : 'post',
data : {'_method':'delete'},(注意:'_method':'delete')
dataType : 'json',
url : url,
success : function(data){
window.location.href="http://localhost:8080/product/findAll.do";
},
error:function(){
window.location.href="http://localhost:8080/product/findAll.do";
}
});

后端使用注解配置
@RequestMapping(value = "/delete/{pid}",method = RequestMethod.DELETE)
public String delete(@PathVariable("pid") String id) throws Exception{}或者:
@DeleteMapping("/delete/{pid}")
br/>或者:
@DeleteMapping("/delete/{pid}")

网页标题:springMVC将post请求转为delete/put请求
网页网址:http://kswjz.com/article/ihsdoc.html

扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流