springboot对SpringMVC的自动配置有哪些?
1 内容协商视图解析器和BeanName视图解析器
2 静态资源(包括webjars)
3 自动注册 Converter,GenericConverter,Formatter
4 自动注册 MessageCodesResolver (国际化用)
5 静态index.html 页支持
6 自定义 Favicon
静态资源访问
这些都是静态资源文件夹
先访问处理器http://localhost:8080/c.jpg若没有,则访问静态资源
添加静态资源访问前缀
spring:
mvc:
static-path-pattern: /res/**
欢迎页
• 静态资源路径下 index.html
• 但是不可以配置静态资源的访问前缀。否则导致 index.html不能被默认访问
RestFul风格的url支持
需要在yml中开启
spring:
mvc:
hiddenmethod:
filter:
enabled: true
<form action="/user" method="get">
<input type="submit" value="GET方式">
</form>
<form action="/user" method="post">
<input type="submit" value="POST方式">
</form>
<form action="/user" method="post">
<input type="hidden" name="_method" value="DELETE">
<input type="submit" value="delete方式">
</form>
<form action="/user" method="post">
<input type="hidden" name="_method" value="PUT">
<input type="submit" value="put方式">
</form>
/
@RequestMapping(value = "/user",method = RequestMethod.GET)
public String getUser(){
return "GET-张三";
}
@RequestMapping(value = "/user",method = RequestMethod.POST)
public String saveUser(){
return "POST-张三";
}
@RequestMapping(value = "/user",method = RequestMethod.PUT)
public String putUser(){
return "PUT-张三";
}
@RequestMapping(value = "/user",method = RequestMethod.DELETE)
public String deleteUser(){
return "DELETE-张三";
}