1. @Configuration(proxyBeanMethods = false)
    2. @ConditionalOnWebApplication(type = Type.SERVLET)
    3. @ConditionalOnClass({ Servlet.class, DispatcherServlet.class, WebMvcConfigurer.class })
    4. @ConditionalOnMissingBean(WebMvcConfigurationSupport.class)
    5. @AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE + 10)
    6. @AutoConfigureAfter({ DispatcherServletAutoConfiguration.class, TaskExecutionAutoConfiguration.class,
    7. ValidationAutoConfiguration.class })
    8. public class WebMvcAutoConfiguration {
    9. ...
    10. @Bean
    11. @ConditionalOnMissingBean(HiddenHttpMethodFilter.class)
    12. @ConditionalOnProperty(prefix = "spring.mvc.hiddenmethod.filter", name = "enabled", matchIfMissing = false)
    13. public OrderedHiddenHttpMethodFilter hiddenHttpMethodFilter() {
    14. return new OrderedHiddenHttpMethodFilter();
    15. }
    16. ...
    17. }

    1、@ConditionalOnMissingBean(HiddenHttpMethodFilter.class)意味着在没有HiddenHttpMethodFilter 时,才执行hiddenHttpMethodFilter()。因此,我们可以自定义filter,改变默认的 _method。例如:

    • 将_method改成_m。 ```java @Configuration(proxyBeanMethods = false) public class WebConfig{ //自定义filter @Bean public HiddenHttpMethodFilter hiddenHttpMethodFilter(){
        HiddenHttpMethodFilter methodFilter = new HiddenHttpMethodFilter();
        methodFilter.setMethodParam("_m");
        return methodFilter;
      
      }
      }

    ```

    2、表单隐藏域的name属性的值:

    <form action=”/user” method=”post”>
    <input name=”_m” type=”hidden” value=”DELETE”/>
    <input value=”REST-DELETE 提交” type=”submit”/>
    </form>