resteasy 集成spring 导致 springmvc拦截器失效

C币不足 sorry...
问题描述:spring springmvc resteasy 集成之后,自定义springmvc拦截器就失效了。控制台能输出--HelloController.hello--,就是进不去拦截器,不知道什么原因,求大佬指教。不甚感激

控制器类
@Controller
@Path("/ws/a")
public class HelloController {

    @POST
    @Path("/aa")
    @Produces(MediaType.APPLICATION_JSON)
    public String hello() {
        System.out.println("--HelloController.hello--");
        return "Hello";// 返回视图组件的名字

    }

}
拦截器类

public class SimpleInterceptor extends HandlerInterceptorAdapter {

    public SimpleInterceptor() {
        System.out.println("==============================================");
    }

    @Override
    public void afterCompletion(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, Exception arg3)
            throws Exception {
        System.out.println("--页面渲染之后我来处理--");
    }

    @Override
    public void postHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, ModelAndView arg3)
            throws Exception {
        System.out.println("--返回响应之后我来处理--");
    }

    @Override
    public boolean preHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2) throws Exception {
        System.out.println("--方法执行之前我来处理--");
        return true;// 继续执行流程
    }

}
web.xml
<servlet>
        <servlet-name>springmvc</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:springmvc-servlet.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>springmvc</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>

    servlet.xml
    <!-- 拦截器 -->
    <mvc:interceptors>
        <mvc:interceptor>
            <mvc:mapping path="/**" />
            <bean class="com.xx.xx.xx.interceptor.SimpleInterceptor" />
        </mvc:interceptor>
    </mvc:interceptors>

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问