Delete
和put
表单请求需要使用method=”post”
并且添加一个隐藏的标签<input name=”_method” type=”hidden” value=”DELETE”
或 ”PUT”
再在yml文件中添加:
Spring:
Mvc:
Hiddenmethod:
Filter:
Enabled: true(默认为false)
只有表单需要这样,客户端不需要配置直接放行
修改_method的方法:
新建类:WebConfig
在其中定义HiddenHttpMethodFilter
方法,需要配置类@Configuration注解,其属性“代理”为false
@Configuration(proxyBeanMethods = false)
Public HiddenHttpMethodFilter hiddenHttpMethodFilter(){
HiddenHttpMethodFilter methodFilter = New HiddenHttpMethodFilter();
methodFilter.setMethodParam(“_m”);
Return methodFilter;
}
请求映射原理:
Springmvc功能分析都是从org.springframework.web.servlet.DispatcherServlet
的doDispatch
方法开始
所有的请求映射都在HandlerMapping
中
-springboot除了自动配置欢迎页的HandlerMapping。访问/能访问到index.html