Spring Batch Admin Webapp无法停止作业,发送Http POST而不是DELETE

时间:2014-09-04 15:59:27

标签: spring spring-batch spring-batch-admin

当尝试从spring-batch-admin webapp(版本1.3.0)中停止作业时,将显示以下错误页面:

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Thu Sep 04 17:57:05 CEST 2014
There was an unexpected error (type=Method Not Allowed, status=405).
Request method 'POST' not supported

控制器期望DELETE方法停止作业,但是从停止按钮开始POST。有谁知道如何解决这个问题?

enter image description here

编辑:我做了一些进一步的研究,偶然发现了一篇来自spring forum的三年帖子。它表明我可能在我的web.xml中遗漏了HiddenMethodFilter。当我将批处理管理器集成到Spring启动应用程序中时,可能存在配置问题。现在我只需要弄清楚如何将我提到的过滤器添加到spring-boot-mvc默认值中。

编辑:我逐渐明白了幕后发生了什么。我问了一个更具体的问题here

感谢任何帮助!

2 个答案:

答案 0 :(得分:1)

可以通过web.xml配置相同的过滤器,如下所示

<filter>
    <filter-name>shallowEtagHeaderFilter</filter-name>
    <filter-class>org.springframework.web.filter.ShallowEtagHeaderFilter</filter-class>
</filter>

<filter>
    <filter-name>hiddenHttpMethodFilter</filter-name>
    <filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
</filter>

<filter-mapping>
    <filter-name>shallowEtagHeaderFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<filter-mapping>
    <filter-name>hiddenHttpMethodFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

答案 1 :(得分:0)

我的servlet配置缺少以下bean:

import org.springframework.web.filter.HiddenHttpMethodFilter;
import org.springframework.web.filter.ShallowEtagHeaderFilter;

@Bean
public Filter shallowEtagHeaderFilter() {
  ShallowEtagHeaderFilter filter = new ShallowEtagHeaderFilter();
  return filter; 
}

@Bean
public Filter hiddenHttpMethodFilter() {
  HiddenHttpMethodFilter filter = new HiddenHttpMethodFilter();      
  return filter;
}