@Aspect @Component public class MethodAspect { @Pointcut("execution(* com.sairobo.heart.modules.app.controller..*.*(..))") public void webLog(){} @Before("webLog()") public void deBefore(JoinPoint joinPoint) throws Throwable { // 接收到请求,记录请求内容 ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); HttpServletRequest request = attributes.getRequest(); HttpServletResponse response = attributes.getResponse(); response.setCharacterEncoding("UTF-8"); response.setContentType("application/json; charset=utf-8"); PrintWriter out = response.getWriter(); String s = null; out.print(s); System.out.println("增强"); }
springboot之AOP(1)前置方法
最新推荐文章于 2024-10-27 20:37:11 发布