
spring
一生有你2020
这个作者很懒,什么都没留下…
展开
-
springboot 使用aop记录访问日志
pom文件增加aop的依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-aop</artifactId> </dependency>自定义注解@Target(ElementType.METHOD)@Retentio原创 2020-05-26 15:39:26 · 331 阅读 · 0 评论 -
Spring boot 使用@RestControllerAdvice、@ExceptionHandler处理全局请求异常
@RestControllerAdvicepublic class ExceptionHandlerController { @ExceptionHandler public JsonContent handler(Exception exception) { ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder .getR.原创 2020-05-26 15:22:03 · 584 阅读 · 0 评论 -
spring 使用 @Around 获取返回值类型
第一种方式MethodSignature methodSignature = (MethodSignature)point.getSignature();Class<?> returnType = methodSignature.getReturnType();第二种方式Method method = ((MethodSignature)point.getSignature()).getMethod();Type type = method.getGenericReturnTy.原创 2020-05-26 14:48:27 · 4705 阅读 · 0 评论 -
spring扫描多个路径,存在两个名称相同的类,扫描时过滤掉
<context:component-scan base-package="com.windf"> <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" /> </context:component-scan> &am原创 2018-04-29 18:19:48 · 3293 阅读 · 0 评论 -
spring filter中使用@Resource注入失败,空指针异常
转载:https://blog.youkuaiyun.com/chl191623691/article/details/78657638web应用启动的顺序是:listener->filter->servlet,所以通过注解时没办法注入的,在filter中注入时,需要手动注入。application.xml<bean id="ssoUserService" class="com.windf....转载 2018-04-29 19:28:03 · 4146 阅读 · 2 评论 -
springMVC 接收map类型参数
前台传递的参数:bean在前台通过字符串拼接成一个map类型的字符串,然后JSON.parse() 后台接口接收参数:原创 2019-01-23 11:21:25 · 4908 阅读 · 0 评论 -
代码重构的技巧——合理使用@Deprecated
转https://www.cnblogs.com/hzhuxin/p/4645070.html我们在做项目时,前期写的类中的一些代码可能由于需求变化的原因需要重写,有时重写时方法的传参和返回值也会发生变化,这样往往导致调用的代码也跟着出错,我们看下spring的代码是如何处理这样的事,先看下面两段代码,上面这段是之前的getHandler方法,现在需要改成第二段代码,方法的参数cache不...转载 2019-04-27 21:14:25 · 396 阅读 · 0 评论 -
SpringMvc参数传递中乱码问题
问题描述:当传递中文参数到controller类时,无乱是get方式还是post方式都出现乱码解决:1、保证所有的页面编码都是utf-8,包括jsp页面,浏览器编码设置和eclipse的编码设置。2、spingmvc给我们提供了一个编码过滤器,只需要在配置文件web.xml中加入即可。如下:<filter> <filter-name>cha...转载 2019-05-05 15:39:07 · 409 阅读 · 0 评论