随笔分类 -  SpringBoot

摘要:通过application类中的main方法里面的run方法 @SpringBootApplication @ServletComponentScan(basePackages = "com.sp") //可以自动将写的servlet扫描进去 配置扫描的包 @MapperScan("com.sp.m 阅读全文
posted @ 2021-07-02 23:30 YuyuFishSmile 阅读(204) 评论(0) 推荐(0)
摘要:编写引导类注意要标明注解 @SpringBootApplication SpringApplication.run(BootWeb01Application.class, args); 再编写main方法的时候使用run方法 起步依赖spring-boot-starter-parent 父工程,主要 阅读全文
posted @ 2021-07-02 21:06 YuyuFishSmile 阅读(72) 评论(0) 推荐(0)
摘要:<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency> spring-boot-autoconfigu 阅读全文
posted @ 2021-07-02 11:11 YuyuFishSmile 阅读(66) 评论(0) 推荐(0)
摘要:引入Mybatis-plus <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.4.3.1</version> </dependency 阅读全文
posted @ 2021-07-01 23:51 YuyuFishSmile 阅读(94) 评论(0) 推荐(0)
摘要:1.配置模式 全局配置文件 SqlsessionFactory:已经自动配置完成 SqlSession: 已经自动配置SqlSessionTemplate,组合了SqlSession,真正对数据库的CRUD用的就是sqlsession Mapper: 只要我们写的操作Mybatis的接口标注了@Ma 阅读全文
posted @ 2021-07-01 21:08 YuyuFishSmile 阅读(100) 评论(0) 推荐(0)
摘要:自定义 1.引入依赖 <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.1.17</version> </dependency> 2.写一个自己的配置类 分析: 在springb 阅读全文
posted @ 2021-07-01 12:34 YuyuFishSmile 阅读(267) 评论(0) 推荐(0)
摘要:1.导入jdbc场景 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> </dependency> jdbc中spring boot帮我 阅读全文
posted @ 2021-06-30 23:42 YuyuFishSmile 阅读(361) 评论(0) 推荐(0)
摘要:需要掌握的是继承接口WebMvcConfigurer这种方式,重写方法 以拦截器为例 @Configuration public class AdminConfig implements WebMvcConfigurer { //所有定制web功能的都是WebMvcConfigurer接口 publ 阅读全文
posted @ 2021-06-30 21:36 YuyuFishSmile 阅读(93) 评论(0) 推荐(0)
摘要:1.使用Servlet API @ServletComponentScan(basePackages = "com.sp") //可以自动将写的servlet扫描进去 配置扫描的包,在BootWeb01Application里面声明注解 @WebServlet(urlPatterns = "/my" 阅读全文
posted @ 2021-06-30 17:39 YuyuFishSmile 阅读(99) 评论(0) 推荐(0)
摘要:自定义404 5xx 页面,在文件夹下添加一个error的文件夹,里面添加对应的html 根据报错显示对应的html 自定义显示,在返回的信息中,浏览器返回的是json,此时包含了5个消息,时间、错误信息、堆栈、路径、状态码,只要是json信息都可以取到,通过thymeleaf里的th:text=" 阅读全文
posted @ 2021-06-30 12:38 YuyuFishSmile 阅读(64) 评论(0) 推荐(0)
摘要:注意: 跳转html文件一定要放在同一个静态资源文件夹下,否则会出现各种报错 文件上传: 首先编写html的form表单提交,对于form表单的上传记得添加enctype,对于多文件上传,需要在input标签下添加multiple <!DOCTYPE html> <html lang="en"> < 阅读全文
posted @ 2021-06-30 12:04 YuyuFishSmile 阅读(242) 评论(0) 推荐(0)
摘要:Ctrl+F12 查看此类的方法,关系有哪些 必须继承这HandlerInterceptor 这个类 类中有三个方法 public class LoginIntercepter implements HandlerInterceptor { @Override public boolean preH 阅读全文
posted @ 2021-06-29 20:20 YuyuFishSmile 阅读(97) 评论(0) 推荐(0)
摘要:对于表单页面也说,F5相当于是再次重复提交表单信息到服务器,此时可以通过重定向来解决 @PostMapping("/login") public String main(String username,String password) { //登陆成功重定向到main.html ,防止表单重复提交 阅读全文
posted @ 2021-06-29 16:53 YuyuFishSmile 阅读(862) 评论(0) 推荐(0)
摘要:<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> 引入thyme leaf starter spr 阅读全文
posted @ 2021-06-29 16:36 YuyuFishSmile 阅读(113) 评论(0) 推荐(0)
摘要:@GetMapping("/send") public String getmessage(HttpServletRequest request) { request.setAttribute("msg","跳转"); //设置参数 request.setAttribute("code",123); 阅读全文
posted @ 2021-06-29 12:32 YuyuFishSmile 阅读(462) 评论(0) 推荐(0)