为什么Spring不支持RequestMethod.LINK?

时间:2019-02-10 12:14:18

标签: java spring spring-boot http

为什么Spring不支持RequestMethod.LINK?如何使用@RequestMapping或其他选项通过LINK方法捕获查询?

1 个答案:

答案 0 :(得分:0)

决定

@RequestMapping("/test")
public int anotherMethods(HttpServletRequest request) {
    if (request.getMethod().equals("LINK")) {
        logger.info("LINK METHOD");
    }
    if (request.getMethod().equals("UNLINK")) {
        logger.info("UNLINK METHOD");
    }
    return HttpStatus.OK.value();
}

并添加

public class SecurityConfig extends WebSecurityConfigurerAdapter {

...
    @Override
    public void configure(WebSecurity web) throws Exception {
        super.configure(web);
        web.httpFirewall(allowHttpMethodsFirewall());
    }

    @Bean
    public HttpFirewall allowHttpMethodsFirewall() {
        StrictHttpFirewall firewall = new StrictHttpFirewall();
        firewall.setAllowedHttpMethods(Arrays.asList("HEAD", "GET", "POST", "PUT", "DELETE", "PATCH", "LINK", "UNLINK"));
        return firewall;
    }

}