【问题标题】:Ajax request omitted by interceptors拦截器忽略 Ajax 请求
【发布时间】:2011-12-26 03:13:10
【问题描述】:

当收到 ajax 请求 (Accept application/json, text/javascript, */*; q=0.01) 时,我需要调用我自己的拦截器方法。

我已将其添加到 DefaultAnnotationHandlerMapping。我的拦截器扩展了HandlerInterceptorAdapter 并实现了ServletContextAwareInitializingBean。我该如何解决我的问题?

【问题讨论】:

    标签: ajax spring model-view-controller


    【解决方案1】:

    你必须手动注册你的拦截器:

    <mvc:interceptors>
        <bean class="com.example.MyCustomInterceptor"/>
    </mvc:interceptors>
    

    另见:

    【讨论】:

    • 我已经使用 注册了拦截器。它不仅适用于 ajax 请求。
    • 你的意思是,如果你用浏览器地址栏输入相同的URL或者使用wget/curl就可以了?
    猜你喜欢
    • 2013-05-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-14
    • 2013-03-07
    • 2016-06-18
    • 1970-01-01
    相关资源
    最近更新 更多