繁体   English   中英

为什么Spring不支持RequestMethod.LINK?

[英]Why does Spring not support RequestMethod.LINK?

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

决定

@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;
    }

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM