Springmvc style used in Rest

Filter Configuration

<filter>
    <filter-name>hidden</filter-name>
	<filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
</filter>
  <filter-mapping>
    <filter-name>hidden</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

2. The distal end corresponding to the configuration request

<form action="/restTest/1" method="post">
	<input type="hidden" name="_method" value="put">
    <input type="submit" value="提交">
</form>

3. backend to accept the request

In an interview here can not jump directly to the request put the interface, because the jump response only supports get and post and head, where you can let it redirect to a request, let it jump!

@RequestMapping(value = "restTest/{id}",method = RequestMethod.PUT)
    public String restTest(@PathVariable Integer id){
        System.out.println("来到了rest测试:"+id);
        return "redirect:/local";
    }
@RequestMapping("local")
    public String local(){
        return "/result";
    }
Published 47 original articles · won praise 6 · views 2197

Guess you like

Origin blog.csdn.net/weixin_44467251/article/details/102705687