springboot进阶

1.springboot配置文件自定义提示

在pom.xml引入配置处理器

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>

2.静态资源配置

配置静态资源访问前缀

spring.mvc.static-path-pattern=/res/**

指定静态资源访问路径,如果不写默认为resources

spring.resources.static-locations=classpath:/haha

3.欢迎页

在静态资源路径下有index.html,会默认访问index页面

controller能处理/index

修改springboot访问图标:将favicon.ico文件放在静态资源路径下就可以了

4.表单页面提交delete和put请求

表单指定method为post,添加隐藏method

<input name="_method" type="hidden" value="delete" />

在springboot配置文件中进行配置

spring.mvc.hiddenmethod.filter.enabled=true

5.处理请求

@PathVariable(路径变量)

@RequestHeader(获取请求头)

@RequestParam(获取请求参数)

@CookieValue(获取cookie值)

@RequestBody(获取请求体的值)

@RequestAttribute(获取request域属性)

@MatrixVariable(获取矩阵变量的值) //默认关闭

一点点学习,一丝丝进步。不懈怠,才不会被时代所淘汰!

原文地址:https://www.cnblogs.com/fqh2020/p/14871316.html