
方案1:
1.1)准备切面,实现权限认证、日志
@Aspect
@Component
public class LogAspect {
Logger logger = LoggerFactory.getLogger(LogAspect.class);
@Value("${spring.application.name}")
private String serverName;
@Pointcut("@annotation(com.xxx.annotation.LogAnnotation)")
public void beforePointCut () {}
@Before("beforePointCut()")
public void before (JoinPoint joinPoint) {
if (joinPoint == null) {
return;
}
HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
String className = joinPoint.getTarget().getClass().getName();
String methodName = joinPoint.getSignature().getName();
Object[] methodArgs = joinPoint.getArgs();
Method method = ((MethodSignature)joinPoint.getSi

本文介绍了两种实现SpringAOP权限认证和日志的方法。方案一涉及创建切面,定义切点注解,并在Action接口的add方法上应用。方案二则通过@Aspect和@Pointcut定义切面,利用AOP的拦截功能。同时,文中还提到了DTO的设计,包括Result对象以及如何在接口中统一返回结果集,遵循JSON规范。
最低0.47元/天 解锁文章
168万+

被折叠的 条评论
为什么被折叠?



