on 2018 Nov 26 2:35 PM
Hello Experts,
Is it possible to implement a custom handler that triggers before a certain request mapping? For example, a handler that triggers only if (/getCustomers) is called. If yes, how could it be implemented.
Thanks in advance
Request clarification before answering.
Hello ,
Write below config in spring-mvc-config.xml in your storefront extension
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/**/getCustomers/**"/>
<mvc:exclude-mapping path="/**/anything-to-exclude-if-needed/**"/>
<bean class="my.package.CustomerHandlerInterceptorAdapter">
//set properties if needed
</bean>
</mvc:interceptor>
</mvc:interceptors>
public class CustomerHandlerInterceptorAdapter extends HandlerInterceptorAdapter
{
@Override
public boolean preHandle(final HttpServletRequest request, final HttpServletResponse response, final Object handler)
throws Exception
{
//Write your logic is true
//If your job is done successfully here then return true else return false
}
}
Hope this helps.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.