2021年12月13日

自定义视图前后缀与Thymeleaf的使用

摘要: 自定义视图前后缀 spring.resources.static-location默认参数指定了Spring Boot-web项目中静态文件存放地址,该参数默认设置为:classpath:/static,classpath:/public,classpath:/resources,classpath 阅读全文

posted @ 2021-12-13 20:03 每天积极向上 阅读(397) 评论(0) 推荐(0) 编辑

2021年12月12日

SpringBoot - 自定义内容协商(HttpMessageConverter)

摘要: 内容协商:根据客户端接收能力不同,返回不同媒体类型的数据。 使返回的数据支持已xml方式返回 <dependency> <groupId>com.fasterxml.jackson.dataformat</groupId> <artifactId>jackson-dataformat-xml</ar 阅读全文

posted @ 2021-12-12 23:09 每天积极向上 阅读(337) 评论(0) 推荐(0) 编辑

SpringBoot - Converter(转换器)

摘要: 自定义转换器 @Configuration(proxyBeanMethods=false) public class AppConfig { @Bean public WebMvcConfigurer getWebMvcConfigurer() { return new WebMvcConfigur 阅读全文

posted @ 2021-12-12 21:42 每天积极向上 阅读(766) 评论(0) 推荐(0) 编辑

SpringMvc - @ModelAttribute注解

摘要: 在SpringMVC的Controller中使用@ModelAttribute时,其位置包括下面三种: 应用在方法上,应用在方法的参数上,应用在方法上并且方法也使用了@RequestMapping 被@ModelAttribute注解的方法会在Controller每个方法执行之前都执行,因此对于一个 阅读全文

posted @ 2021-12-12 15:29 每天积极向上 阅读(82) 评论(0) 推荐(0) 编辑

SpringMvc - @SessionAttributes注解

摘要: @SessionAttributes 默认情况下Spring MVC将模型中的数据存储到request域中。当一个请求结束后,数据就失效了。如果要跨页面使用。那么需要使用到session。而@SessionAttributes注解就可以使得模型中的数据存储一份到session域中。 有三个参数: 1 阅读全文

posted @ 2021-12-12 15:08 每天积极向上 阅读(44) 评论(0) 推荐(0) 编辑

2021年12月11日

SpringBoot - 静态资源访问

摘要: 1.在springboot项目种默认访问静态资源是在resources(classpath:/)下的这四个文件夹顺序为: META-INF/resources > resources > static > public 2.设置视图解析器前缀与后缀 spring: mvc: view: #1.设置视 阅读全文

posted @ 2021-12-11 21:56 每天积极向上 阅读(164) 评论(0) 推荐(0) 编辑

SpringBoot - 绑定配置文件注解

摘要: @ImportResource @ImportResource注解用于导入Spring的配置文件,让配置文件里面的内容生效;(就是以前写的springmvc.xml、applicationContext.xml)Spring Boot里面没有Spring的配置文件,我们自己编写的配置文件,也不能自动 阅读全文

posted @ 2021-12-11 16:42 每天积极向上 阅读(558) 评论(0) 推荐(0) 编辑

SpringBoot - 条件注解

摘要: @Conditional注解可以添加在@Configuration、@Component、@Service等修饰的类上用于控制对应的Bean是否需要创建,或者添加在@Bean修饰的方法上用于控制方法对应的Bean是否需要创建。 1.Bean作为条件 @ConditionalOnBean @Condi 阅读全文

posted @ 2021-12-11 15:43 每天积极向上 阅读(121) 评论(0) 推荐(0) 编辑

SpringBoot - 目录

摘要: Spring Boot 是 Pivotal 团队在 Spring 的基础上提供的一套全新的开源框架,其目的是为了简化 Spring 应用的搭建和开发过程。Spring Boot 去除了大量的 XML 配置文件,简化了复杂的依赖管理。 Spring Boot 具有 Spring 一切优秀特性,Spri 阅读全文

posted @ 2021-12-11 15:19 每天积极向上 阅读(131) 评论(0) 推荐(0) 编辑

SpringBoot - @Configuration与@Import

摘要: @Configuration proxyBeanMethods配置类是用来指定@Bean注解标注的方法是否使用代理,默认是true使用代理,直接从IOC容器之中取得对象; 如果设置为false,也就是不使用注解,每次调用@Bean标注的方法获取到的对象和IOC容器中的都不一样,是一个新的对象; 所以 阅读全文

posted @ 2021-12-11 15:10 每天积极向上 阅读(1283) 评论(0) 推荐(0) 编辑

导航