Spring Interceptors
applicationContext-dispatcher.xml
we can configure the interceptors as follows in this.
<bean id="visitedPageInterceptor" class="au.com.vvv.oes.ui.controller.interceptor.VisitedPageInterceptor"/>
<bean id="trailingSlashInterceptor" class="au.com.vvv.oes.ui.controller.interceptor.TrailingSlashInterceptor"/>
<bean id="breadcrumbInterceptor" class="au.com.vvv.oes.ui.controller.interceptor.BreadcrumbInterceptor"/>
<bean id="ie6Interceptor" class="au.com.vvv.oes.ui.controller.interceptor.IE6Interceptor"/>
<bean id="SEOInterceptor" class="au.com.vvv.oes.ui.controller.interceptor.SEOInterceptor"/>
we can configure the interceptors as follows in this.
These interceptors can be post interceptors or preinterceptors.
example visitedPageInterceptor will be as follows,
package au.com.vvv.oes.ui.controller.interceptor;
public class VisitedPageInterceptor extends HandlerInterceptorAdapter {
@Autowired
private OrderHelper orderHelper;
private OrderHelper orderHelper;
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
}
}
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
String contextUrl = request.getServletPath();
if (contextUrl != null) {
if (ArrayUtils.contains(VISITED_PAGE_ENABLED_URLS, contextUrl)) {
HttpSession session = request.getSession();
session.setAttribute(LAST_VISITED_PAGE, contextUrl);
String queryString = request.getQueryString();
if (isNotBlank(queryString)) {
session.setAttribute(LAST_VISITED_PAGE, contextUrl + "?" + queryString);
}
}
if (contextUrl.indexOf(MOBILES_ORDER) > -1) {
createBackButtonLinks(request);
}
return true;
}
String contextUrl = request.getServletPath();
if (contextUrl != null) {
if (ArrayUtils.contains(VISITED_PAGE_ENABLED_URLS, contextUrl)) {
HttpSession session = request.getSession();
session.setAttribute(LAST_VISITED_PAGE, contextUrl);
String queryString = request.getQueryString();
if (isNotBlank(queryString)) {
session.setAttribute(LAST_VISITED_PAGE, contextUrl + "?" + queryString);
}
}
if (contextUrl.indexOf(MOBILES_ORDER) > -1) {
createBackButtonLinks(request);
}
return true;
}
}
<bean id="catalogueFilterInterceptor" class="au.com.vvv.oes.ui.controller.interceptor.CatalogueFilterInterceptor"/>
Comments
Post a Comment