首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >只拦截使用HandlerInterceptorAdapter类的GET请求

只拦截使用HandlerInterceptorAdapter类的GET请求
EN

Stack Overflow用户
提问于 2017-08-17 09:55:46
回答 1查看 703关注 0票数 1

是否可能只在spring引导应用程序中拦截GET请求?

addPathPatterns()方法不能解决我的目的。

我想根据他们的请求方法排除或包括被截获的请求。

例如:

  1. 只拦截GET请求
  2. 只拦截GET和POST请求。

应用程序将接收GET、POST、PUT和DELETE请求。

EN

回答 1

Stack Overflow用户

发布于 2019-08-30 15:27:00

其实你可以。您将拦截所有方法,但必须使用getMethod()从请求中筛选它们。这是它的javadoc:

代码语言:javascript
复制
 /**
     * Returns the name of the HTTP method with which this 
     * request was made, for example, GET, POST, or PUT.
     * Same as the value of the CGI variable REQUEST_METHOD.
     *
     * @return          a <code>String</code> 
     *              specifying the name
     *              of the method with which
     *              this request was made
     */
    public String getMethod();
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45731965

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档