spring MVC模式拦截所有入口方法的入参出参打印
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component; import java.lang.reflect.Method;
@Component
@Aspect
public class MvcMethodLogAdvice { private static Logger log = LoggerFactory.getLogger(MvcMethodLogAdvice.class); @Around("@annotation(org.springframework.web.bind.annotation.RequestMapping)")
public Object aroundAdvice(ProceedingJoinPoint joinPoint) throws Throwable { Object args[] = joinPoint.getArgs();
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
// join arguments.
log.info("{}.{} : 请求参数:{} ", method.getDeclaringClass().getName(), method.getName(), StringUtils.join(args, " ; "));
long start = System.currentTimeMillis();
Object result = joinPoint.proceed();
long timeConsuming = System.currentTimeMillis() - start;
log.info("调用结束--> 返回值:{} 耗时:{}ms", JSONObject.toJSONString(result, SerializerFeature.WriteMapNullValue), timeConsuming);
return result;
}
}
在你的项目中加入这个类就好,这样设置之后,就会打印这样的日志

对日后定位问题极有助益
spring MVC模式拦截所有入口方法的入参出参打印的更多相关文章
- Spring mvc 模式小结
http://www.taobaotesting.com/blogs/2375 1.spring mvc简介 Spring MVC框架是一个MVC框架,通过实现Model-View-Controlle ...
- spring mvc +cookie+拦截器功能 实现系统自动登陆
先看看我遇到的问题: @ResponseBody @RequestMapping("/logout") public Json logout(HttpSession session ...
- 玩转spring MVC(七)----拦截器
继续在前边的基础上来学习spring MVC中拦截器的使用,下面通过一个例子来实现(完整项目在这里下载:http://download.csdn.net/detail/u012116457/84334 ...
- Spring mvc登录拦截器
自己实现的第一个Spring mvc登录拦截器 题目要求:拒绝未登录用户进入系统,只要发现用户未登录,则将用户请求转发到/login.do要求用户登录 实现步骤: 1.在spring的配置文件中添加登 ...
- Spring MVC 跳转页面的方法
转一个Spring MVC 跳转页面的方法,楼主总结的很全面,留着备用. https://blog.csdn.net/c_royi/article/details/78528758
- 基于Spring MVC 实现拦截器
Spring MVC 拦截器 一,具体内容: 在所有的开发之中拦截器属于一个重要的组件,可以说几乎所有的项目都会提供的概念应用,不管是Spring MVC,还是Struts 2.x都是提供有拦截器的, ...
- [Spring MVC] - Interceptor 拦截器
Spring MVC中的Interceptor与Struts2的差不多. 下面是一个简单的Interceptor登陆验证例子: 1.需要在spring的配置文件中加入这段: <!-- 自定义拦截 ...
- spring mvc 配置文件拦截器过滤url
最近在用spring mvc拦截器,sprin 版本号4.0.6.RELEASE, <mvc:interceptor> <mvc:mapping path="/admin/ ...
- Spring MVC定义拦截器
拦截器: package sy.Interceptor; import javax.servlet.http.HttpServletRequest; import javax.servlet.http ...
随机推荐
- LG3565 [POI2014]HOT-Hotels
题意 有一个树形结构,每条边的长度相同,任意两个节点可以相互到达.选3个点.两两距离相等.有多少种方案? 1≤n≤5 000 分析 参照小塘空明的题解. 很明显到一个点距离相等的三个点两两之间距离相等 ...
- Python中实现远程调用(RPC、RMI)简单例子
说白了,远程调用就是将对象名.函数名.参数等传递给远程服务器,服务器将处理结果返回给客户端 远程调用使得调用远程服务器的对象.方法的方式就和调用本地对象.方法的方式差不多,因为我们通过网络编程把这 ...
- laravel的学习历程
首要,表明态度:PHP是世界上最佳的言语.(梗) laravel说是php将来,形似不假. 最开端触摸的是thinkphp,格外喜爱她的分层,文档格外完全,阅读起来没任何妨碍. 比较laravel,我 ...
- Centos用yum升级mysql到(5.5.37) (转)
http://www.cnblogs.com/ikodota/p/use_yum_update_mysql.html 1. Change root user su - ## OR ## sudo -i ...
- checkstyle简单使用说明
checkstyle对检查代码规范问题的总结,虽然还不够只能,但已经比较强大.1.Cyclomatic Complexity is X (max allowed is X). 问题说明:圈复杂度过高. ...
- (新)解决php版本ueditor中动态配置图片URL前缀(imageurlprefix)的方法
昨天晚上写了一篇文章<解决ueditor中没法动态配置imageurlprefix的方法>,通过修改js获取当前域名的方法,配置imageurlprefix值: 发现还是不够灵活,因为域名 ...
- maven中项目发布jar包不同步
昨天的项目今天运行的时候突然发现今天就不能运行了 严重: Error configuring application listener of class org.springframework.web ...
- GOF23设计模式之迭代器模式(iterator)
一.迭代器模式概述 提供一种可以遍历聚合对象的方式.又称为:游标(cursor)模式 结构: (1)聚合对象:存储数据 (2)迭代器:遍历数据 二.迭代器模式示例代码 定义:正向遍历迭代器和逆向遍历迭 ...
- java代码------实现从控制台输入整型,
总结:主要是方法的调用不能错,比如浮点型,整型,字节型,so.on int ====hasNextInt() float--------hasNextfloat() short ====hasNext ...
- 007:MySQL SSL
一. SSL安装 SSL(Secure Socket Layer)是维护Client - Server之间加密通讯的一套安全协议: --默认ssl未开启 mysql> show variable ...