本文介绍了弹簧拦截器永远不会被调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下拦截器:
@Component
public class ExternalLinkInterceptor extends HandlerInterceptorAdapter {
private static final Logger logger = Logger.getLogger(ExternalLinkInterceptor.class);
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
logger.info("preHandle ~ invoked");
}
}
应该在对以下控制器方法的请求句柄之前进行拦截:
it is supposed to intercept before request handle to the following controller method:
@Controller
@PreAuthorize("isAuthenticated()")
@RequestMapping("/assay/process")
public class VariantPrioritizationsController extends AssayBaseController{
private static final Logger logger = Logger.getLogger(VariantPrioritizationsController.class);
@RequestMapping("/openAnalyticalProjectForAssay")
public ModelAndView openAnalyticalProjectForAssay(HttpSession session,@RequestParam(value = "analyticalProjId", required=true)String projectId) throws PanDaApplicationException{
//code
}
}
这是spring-servlet.xml中的拦截器声明:
this is the interceptor declaration in the spring-servlet.xml:
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/assay/process/openAnalyticalProjectForAssay*"/>
<beans:bean class="com.syngenta.panda.web.mvc.interceptor.ExternalLinkInterceptor"/>
</mvc:interceptor>
</mvc:interceptors>
现在我的拦截器从未被调用过,我也不知道为什么?!任何帮助
now my interceptor is never invoked and I don't know why?! any help
推荐答案
请尝试将mvc:mapping路径更新为:
Please try updating the mvc:mapping path to:
<mvc:mapping path="/assay/process/**" />
这篇关于弹簧拦截器永远不会被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!