hybris - Which Spring Controller is serving my req

2020-07-13 11:10发布

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?

2条回答
劳资没心,怎么记你
2楼-- · 2020-07-13 11:37

U can use eclipse to search the path or action specified. Mostly all the actions are mapped to the respective controller. For Ex: any action related to the search are mapped to the SearchPageController.java and any action related to Product will be mapped to ProductPageController.java. Hope this helps...

查看更多
趁早两清
3楼-- · 2020-07-13 11:48

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.

查看更多
登录 后发表回答