发表于: 2018-03-05 22:46:25

1 530


今天完成的事:

一、

1、aop获取请求对象啊的内容

  @Before("log()")
public void before(JoinPoint joinPoint){
logger.info("111111前置方法执行");
       ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
       HttpServletRequest request = attributes.getRequest();

//        url
       logger.info("url={}",request.getRequestURL());

//      method
       logger.info("method={}",request.getMethod());

//        ip
       logger.info("ip={}",request.getRemoteAddr());

//        类方法
       logger.info("class={}",joinPoint.getSignature().getDeclaringTypeName()+"."+joinPoint.getSignature().getName());

//        参数
       logger.info("args={}",joinPoint.getArgs());
   }

1、对象JoinPoint

2、表单验证 not null 和not blank 和not empty的区别

@NotEmpty 用在集合类上面 
@NotBlank 用在String上面 
@NotNull 用在基本类型上


二、异常的处理


@ExceptionHandler(value = Exception.class)


遇到的困难:

1、namespace是生成mapper接口的类名

<mapper namespace="com.how2java.springboot.mapper.CategoryMapper" >

2、springboot配置文件中加载mybatis的xml文件

mybatis.mapper-locations=classpath*:mapper/*.xml


注意:mybatis逆向生成时一定要和project的目录一致否则得改全限定类名


返回列表 返回列表
评论

    分享到