【发布时间】:2017-01-12 16:18:54
【问题描述】:
我正在尝试实现HandlerInterceptorAdapter 以便能够将请求/响应捕获为前/后处理器。由于某种原因,呼叫没有通过我的拦截器。有多个示例,但我在我的案例中找不到问题。现在我想在请求进入实际服务之前捕获请求并记录一些数据。
注意:我没有要渲染的视图。
拦截器类:
public class ESignLoggingInterceptor extends HandlerInterceptorAdapter {
private static final String CLASS_NAME = ESignLoggingInterceptor.class.getSimpleName();
@SuppressWarnings("unused")
@Override
public boolean preHandle( HttpServletRequest request, HttpServletResponse response, Object handler ) throws Exception {
String url = null;
if( request != null ) {
url = request.getRequestURL().toString();
}
return true;
}
}
spring.xml
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/rest"/>
<bean class="com.mercuryinsurance.esignature.common.logging.ESignLoggingInterceptor" />
</mvc:interceptor>
</mvc:interceptors>
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/soap"/>
<bean class="com.mercuryinsurance.esignature.common.logging.ESignLoggingInterceptor" />
</mvc:interceptor>
</mvc:interceptors>
【问题讨论】: