最近在研究spring mvc拦截器,那么今天也算个学习笔记吧!有需要了解使用Spring MVC拦截器实现日志记录的朋友可参考。希望此文章对各位有所帮助。 定义一个类实现HandlerInterceptor,比如:
最近在研究spring mvc拦截器,那么今天也算个学习笔记吧!有需要了解使用Spring MVC拦截器实现日志记录的朋友可参考。希望此文章对各位有所帮助。
定义一个类实现HandlerInterceptor,比如:
public class MyInterceptors implements HandlerInterceptor{ public void afterCompletion(httpservletRequest arg0, HttpServletResponse arg1, Object arg2, Exception arg3) throws Exception { // TODO Auto-generated method stub System.out.println("MyInterceptors afterCompletion"); } public void postHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, ModelAndView arg3) throws Exception { // TODO Auto-generated method stub System.out.println("MyInterceptors postHandle"); } public boolean preHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2) throws Exception { // TODO Auto-generated method stub HandlerMethod handlerMethod = (HandlerMethod) arg2; System.out.println("MyInterceptors preHandle 调用方法名:"+handlerMethod.getMethod().getName()); return true; } }
--结束END--
本文标题: 使用Spring MVC拦截器实现日志记录的方法
本文链接: https://www.lsjlt.com/news/227025.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0