4

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

4

2 回答 2

4

请尝试将 mvc:mapping 路径更新为:

<mvc:mapping path="/assay/process/**" />
于 2013-05-14T17:38:52.813 回答
-1

mvc:interceptor 的配置对我来说看起来不正确。我之前从 Spring 中使用过语言环境更改拦截器,它们的配置非常简单:

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

这个拦截器只是在 URL 上寻找一个参数来改变用户选择的语言环境。

该视频介绍了包括语言环境拦截器在内的所有内容的设置:

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

于 2013-05-14T17:14:43.937 回答