springboot
落叶飘淋雨
这个作者很懒,什么都没留下…
展开
-
springboot整合mybatis-plus实现分页
导入依赖 <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.4.1</version> </dependency>2、实体类@AllArgsC原创 2021-05-27 06:08:18 · 379 阅读 · 1 评论 -
springboot文件上传
页面表单<form method="post" action="/upload" enctype="multipart/form-data"> <input type="file" name="file"><br> <input type="submit" value="提交"></form>前端代码<form role="form" th:action="@{/upload}" method="post" enct原创 2021-05-25 17:09:07 · 58 阅读 · 0 评论 -
springboot-转发的值传递
路径转发进行值传递@RequestMapping("/forward") public String goTo(HttpServletRequest httpServletRequest){ httpServletRequest.setAttribute("msg","成功"); httpServletRequest.setAttribute("code",200); return "forward:/success"; } @R原创 2021-05-15 15:38:17 · 240 阅读 · 0 评论 -
springboot-参数传递注解
1.1、注解:@PathVariable、@RequestHeader、@ModelAttribute、@RequestParam、@MatrixVariable、@CookieValue、@RequestBody@RestControllerpublic class ParameterTestController { // car/2/owner/zhangsan @GetMapping("/car/{id}/owner/{username}") public Map&原创 2021-05-14 15:01:27 · 1110 阅读 · 0 评论 -
springboot-web静态资源访问
静态资源目录静态资源只要放在类路径下(static、public、resources、META-INF/resources目录)都会被自动访问到访问方式:当前项目根路径/+静态资源名(http://localhost:8080/abc.html)原理:静态映射/**请求进来,先去找controller看能不能处理,不能处理的所有请求就交给静态资源处理器,静态资源也找不到则响应404页面。改变默认的静态资源路径#设置静态资源的访问前缀,默认无前缀spring: mvc: static原创 2021-05-09 16:32:37 · 99 阅读 · 1 评论 -
springboot-SpringMVC自动配置
SpringMVC自动配置概览Spring Boot provides auto-configuration for Spring MVC that works well with most applications.(大多场景我们都无需自定义配置)The auto-configuration adds the following features on top of Spring’s defaults:• Inclusion of ContentNegotiatingViewResolver and原创 2021-05-09 15:56:21 · 123 阅读 · 0 评论 -
springboot的yml文件使用
基本语法key: value;kv之间有空格大小写敏感使用缩进表示层级关系缩进不允许使用tab,只允许空格缩进的空格数不重要,只要相同层级的元素左对齐即可'#‘表示注释字符串无需加引号,如果要加,’‘与"“表示字符串内容 会被 转义/不转义(”/n"输出会换行,’/n’输出不会换行)数据类型![在这里插入图片描述](https://img-blog.csdnimg.cn/20210507214531389.png?x-oss-process=image/watermark,type_ZmF原创 2021-05-07 21:48:48 · 237 阅读 · 0 评论 -
springboot自动配置注解的使用
1、组件添加@Configuration默认是Full模式配置类组件之间无依赖关系用Lite模式加上容器启动过程,减少判断配置组件之间有依赖关系,方法会被调用得到之前单实例组件,用Full模式#############################Configuration使用示例######################################################/** * 1、配置类里面使用@Bean标注在方法上给容器注册组件,默认也是单实例的 * 2、配置类本身原创 2021-04-29 08:31:11 · 267 阅读 · 0 评论 -
springboot自动配置
1、自动配置Tomcat•引入tomcat依赖•配置好tomcat2、自动配置好SpringMVC• 引入SpringMVC全套组件• 配置好SpringMVC组件(功能)3、自动配置好web功能,如字符编码问题•springboot帮我们配置好了所以web开发的应用场景4、默认包结构•主程序所在的包及其下面的所有子包的组件都会被默认扫描进来•无需以前的包扫描配置• 想要改变扫描路径,@SpringBootApplication(scanBasePackages=“com.atguig原创 2021-04-29 02:16:36 · 202 阅读 · 0 评论 -
springboot的优缺点
优点:1、创建独立spring应用2、内嵌web服务器3、自动starter依赖,简化构建配置4、自动配置spring以及第三方功能5、提供生产级别的监控、健康检查及外部化配置6、无代码生成,不需编写xml缺点:1、迭代快需要时刻关注变化2、封装太深、内部原理复杂、不易精通...原创 2021-04-29 01:32:04 · 560 阅读 · 0 评论