两个地方需要注意:
第一处在web.xml文件中不要忘记配置
<filter> <filter-name>HiddenHttpMethodFilter</filter-name> <filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class> </filter> <filter-mapping> <filter-name>HiddenHttpMethodFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
第二处是在方法开头加上注解@ResponseBody,代码如下所示
@RequestMapping(value="/testRest/{id}",method=RequestMethod.PUT) @ResponseBody public String testRestPut(@PathVariable Integer id){ System.out.println("testRest Put:" + id); return SUCCESS; } @RequestMapping(value="/testRest/{id}",method=RequestMethod.DELETE) @ResponseBody public String testRestDelete(@PathVariable Integer id){ System.out.println("testRest Delete:" + id); return SUCCESS; }
然后就成功了。
原文地址:https://www.cnblogs.com/liaoxiaolao/p/9994188.html
时间: 2024-11-04 06:48:01