Spring interceptor is never called

I have the following interceptor:

@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 must intercept the following controller method before processing the request:

 @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 } } 

this is an interceptor declaration in 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 called, and I don't know why ?! any help

+4
source share
2 answers

Try updating the mvc: map path to:

 <mvc:mapping path="/assay/process/**" /> 
+4
source

Configuration for mvc: interceptor doesn't look right for me. I used the language change hooks before Spring, and their configuration is very simple:

 <mvc:interceptors> <bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" p:paramName="language"/> </mvc:interceptors> 

This interceptor simply searches for the URL parameter to change the locale selected by the user.

This video goes through setting everything up, including the local interceptor:

http://pluralsight.com/training/Courses/TableOfContents/springmvc-intro

-1
source

Source: https://habr.com/ru/post/1480759/


All Articles