Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

hybris - Which Spring Controller is serving my request?

I'd like to set a breakpoint in a certain Controller to debug it. But with all the Spring XML declaration files and annotations in my hybris application, it's hard to tell which Spring Controller is finally serving a certain HTTP request.

Is there an easy way in hybris to know which Controller serves a certain HTTP request? Maybe some tool where you can enter a URL and it tells you to which Controller the request will resolve. Or maybe refining the logging for a certain Spring class that will log this information?

like image 359
Henrique Ordine Avatar asked Jan 27 '14 09:01

Henrique Ordine


1 Answers

You can extend the Spring class HandlerInterceptorAdapter to create a new interceptor which will be invoked before the Controller is invoked.

In it's preHandle(HttpServletRequest, HttpServletResponse, Object handler) method, the handler is the controller wich will serve the request, and therefore you can log the controller's name in your log files. Remember to set the log level accordingly for this class.

You need to add this interceptor to <mvc:interceptors> in your spring-mvc-config.xml.

like image 60
Pearl Jade Avatar answered Oct 18 '22 10:10

Pearl Jade