上一页 1 ··· 38 39 40 41 42 43 44 45 46 ··· 108 下一页
摘要: 使用Servlet3.0的注解进行配置步骤 启动类里面加@ServletComponentScan,进行扫描 新建一个Filter类,implements Filter,并实现对应的接口 @WebFilter标记一个类为filter,被spring扫描 urlPatterns:拦截规则,支持正则 控 阅读全文
posted @ 2020-07-05 13:37 陈彦斌 阅读(730) 评论(0) 推荐(0)
摘要: 返回自定义异常界面,需要引入thymeleaf依赖(非必须,如果是简单的html界面则不用) <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</art 阅读全文
posted @ 2020-07-05 10:58 陈彦斌 阅读(1058) 评论(0) 推荐(0)
摘要: 全局异常处理 为什么要配全局异常? 不配全局服务端报错场景,1/0、空指针等 配置好处 统一的错误页面或错误码 对用户更友好 配置全局异常 第一步类添加注解 @ControllerAdvicce,如果需要返回JSON数据,则方法需要加@ReponseBody @RestControllerAdvic 阅读全文
posted @ 2020-07-05 10:19 陈彦斌 阅读(1203) 评论(0) 推荐(0)
摘要: 引入相关依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <ex 阅读全文
posted @ 2020-07-04 22:36 陈彦斌 阅读(229) 评论(0) 推荐(0)
摘要: 配置文件加载 方式一 Controller上面配置@PropertySource({"classpath:pay.properties"}) 添加属性@Value("wxpay.appid") private String payAppid; pay.properties # 微信支付的appid 阅读全文
posted @ 2020-07-04 22:07 陈彦斌 阅读(1665) 评论(0) 推荐(1)
上一页 1 ··· 38 39 40 41 42 43 44 45 46 ··· 108 下一页