Muhammad Bekette
Muhammad Bekette

Reputation: 1434

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

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

Upvotes: 4

Views: 3544

Answers (2)

Ketan
Ketan

Reputation: 1012

Please try updating the mvc:mapping path to:

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

Upvotes: 4

bh5k
bh5k

Reputation: 880

The configuration for the mvc:interceptor doesn't look correct to me. I have used the locale change interceptors before from Spring and their configuration is very simple:

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

This interceptor just looks for a param on the URL to change the locale that the user has selected.

This video walks through the setup of everything including the locale interceptor:

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

Upvotes: -1

Related Questions