hybris - Which Spring Controller is serving my request?

﹥>﹥吖頭↗ 提交于 2019-12-12 08:54:48

问题


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?


回答1:


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.




回答2:


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...



来源:https://stackoverflow.com/questions/21377187/hybris-which-spring-controller-is-serving-my-request

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!