hybris - 哪个Spring控制器正在服务我的请求? [英] hybris - Which Spring Controller is serving my request?

查看:112
本文介绍了hybris - 哪个Spring控制器正在服务我的请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在某个控制器中设置断点来调试它。
但是对于我的hybris应用程序中的所有Spring XML声明文件和注释,很难知道哪个Spring控制器最终为某个HTTP请求提供服务。

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.

有一个简单的方法hybris知道哪个Controller服务一个特定的HTTP请求?也许一些工具,你可以输入一个URL,它告诉你请求将解决哪个控制器。

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?

推荐答案

你可以扩展Spring类 HandlerInterceptorAdapter 创建一个

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

preHandle(HttpServletRequest,HttpServletResponse,Object handler)方法,处理程序是将为请求提供服务的控制器,因此您可以在日志文件中记录控制器的名称。请记得为此类设置相应的日志级别。

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.

您需要将此拦截器添加到< mvc:interceptors> 在你的spring-mvc-config.xml中。

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

这篇关于hybris - 哪个Spring控制器正在服务我的请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆