Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot Spring Boot 2.2.0.RELEASE未映射ELEAF put和delete请求_Spring Boot_Thymeleaf - Fatal编程技术网

Spring boot Spring Boot 2.2.0.RELEASE未映射ELEAF put和delete请求

Spring boot Spring Boot 2.2.0.RELEASE未映射ELEAF put和delete请求,spring-boot,thymeleaf,Spring Boot,Thymeleaf,从Spring Boot 2.1.6.RELEASE升级到2.2.0.RELEASE后,在嵌入式Tomcat上执行PUT和DELETE时,基于ThymileAF的页面失败。获取和发布工作正常 我在Chrome developer tools中看到正在发送以下请求: 请求URL:https://localhost:8443/notifications/1 申请方式:邮寄 请求正文包含_method=“put”和_csrf令牌 有趣的是,我用@SpringBootTest注释的集成测试正在通过 Sp

从Spring Boot 2.1.6.RELEASE升级到2.2.0.RELEASE后,在嵌入式Tomcat上执行PUT和DELETE时,基于ThymileAF的页面失败。获取和发布工作正常

我在Chrome developer tools中看到正在发送以下请求:

请求URL:https://localhost:8443/notifications/1 申请方式:邮寄

请求正文包含_method=“put”和_csrf令牌

有趣的是,我用@SpringBootTest注释的集成测试正在通过

Spring引导执行器显示/notifications/{notificationId}映射到PUT

切换回2.1.6.RELEASE解决了这个问题

我的ThymileAF表格定义如下:

<form id="notificationForm" th:action="@{/notifications/{notificationId}(notificationId=${notification.id})}" th:object="${notification}" th:method="put" class="needs-validation" novalidate autocomplete="off">
  @PutMapping("/notifications/{notificationId}")
  public String updateNotification(@PathVariable("notificationId") final Long notificationId,
      @Valid @ModelAttribute(name = NOTIFICATION_MODEL_ATTRIBUTE) final NotificationDto notificationDto,
      final BindingResult result, final Model model, final RedirectAttributes attributes) 
执行删除操作时,控制台中将显示以下堆栈跟踪:

org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported
    at org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping.handleNoMatch(RequestMappingInfoHandlerMapping.java:201)
    at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.lookupHandlerMethod(AbstractHandlerMethodMapping.java:421)
    at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:367)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.getHandlerInternal(RequestMappingHandlerMapping.java:449)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.getHandlerInternal(RequestMappingHandlerMapping.java:67)
    at org.springframework.web.servlet.handler.AbstractHandlerMapping.getHandler(AbstractHandlerMapping.java:393)
    at org.springframework.web.servlet.DispatcherServlet.getHandler(DispatcherServlet.java:1234)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1016)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
...
这就好像Spring在解析映射之前没有使用_方法执行必要的方法转换

有人有什么想法吗

这就好像Spring在解析映射之前没有使用_方法执行必要的方法转换

这就是正在发生的事情。此转换由
HiddenHttpMethodFilter
执行,它是:

默认情况下,处理
\u方法
请求参数的筛选器现在被禁用,因为如果请求正文可能包含参数,它会导致提前使用请求正文。这可以通过将
spring.webflux.hiddenmethod.filter.enabled
spring.mvc.hiddenmethod.filter.enabled
设置为true来恢复

您正在使用SpringMVC,因此应该设置
Spring.MVC.hiddenmethod.filter.enabled=true