2013-12-04 2 views
1

Я использую весной 3.2.4, и я прочитал, что Spring MVC 3.2.x явно поддерживает метод PATCH HTTP:PATCH в котом с Spring MVC

https://jira.springsource.org/browse/SPR-7985

http://docs.spring.io/spring/docs/3.2.0.RC1/reference/html/new-in-3.2.html

Однако, когда я развертываю свое приложение в Tomcat (7.0.41), я систематически получаю ошибку 501 при использовании метода PATCH.

Почему это не работает? Есть ли способ заставить его работать? Должен ли я использовать другой контейнер вместо Tomcat?

EDIT:

Вот моя web.xml:

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> 

<welcome-file-list> 
    <welcome-file>index.html</welcome-file> 
</welcome-file-list> 

<context-param> 
    <param-name>contextClass</param-name> 
    <param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value> 
</context-param> 

<filter> 
    <filter-name>springSecurityFilterChain</filter-name> 
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> 
</filter> 
<filter-mapping> 
    <filter-name>springSecurityFilterChain</filter-name> 
    <url-pattern>/*</url-pattern> 
</filter-mapping> 

И мои зависимости:

<dependency> 
    <groupId>org.springframework</groupId> 
    <artifactId>spring-core</artifactId> 
</dependency> 
<dependency> 
    <groupId>org.springframework</groupId> 
    <artifactId>spring-context</artifactId> 
</dependency> 
<dependency> 
    <groupId>org.springframework</groupId> 
    <artifactId>spring-beans</artifactId> 
</dependency> 
<dependency> 
    <groupId>org.springframework</groupId> 
    <artifactId>spring-web</artifactId> 
</dependency> 
<dependency> 
    <groupId>org.springframework</groupId> 
    <artifactId>spring-webmvc</artifactId> 
</dependency> 
<dependency> 
    <groupId>org.springframework</groupId> 
    <artifactId>spring-jdbc</artifactId> 
</dependency> 
<dependency> 
    <groupId>org.springframework</groupId> 
    <artifactId>spring-orm</artifactId> 
</dependency> 
<dependency> 
    <groupId>org.springframework</groupId> 
    <artifactId>spring-tx</artifactId> 
</dependency> 
<dependency> 
    <groupId>org.springframework.data</groupId> 
    <artifactId>spring-data-commons</artifactId> 
</dependency> 
<dependency> 
    <groupId>org.springframework.data</groupId> 
    <artifactId>spring-data-jpa</artifactId> 
</dependency> 
<dependency> 
    <groupId>org.springframework.security</groupId> 
    <artifactId>spring-security-core</artifactId> 
</dependency> 
<dependency> 
    <groupId>org.springframework.security</groupId> 
    <artifactId>spring-security-config</artifactId> 
    <scope>runtime</scope> 
</dependency> 
<dependency> 
    <groupId>org.springframework.security</groupId> 
    <artifactId>spring-security-web</artifactId> 
    <scope>runtime</scope> 
</dependency> 

Спасибо заранее,

Jerome

+0

Можете ли вы показать свои зависимости (банки) и настройку сервлета? Spring Framework FrameworkServlet поддерживает метод PATCH независимо от версии tomcat (сервлета). –

ответ

3

ОК, я, наконец, нашел решение: http://docs.spring.io/spring/docs/3.2.5.RELEASE/spring-framework-reference/htmlsingle/#mvc-ann-form-urlencoded-data

Для поддержки HTTP PUT и PATCH запросы, весна-веб-модуль обеспечивает фильтр HttpPutFormContentFilter, который может быть сконфигурирован в web.xml:

<filter> 
    <filter-name>httpPutFormFilter</filter-name> 
    <filter-class>org.springframework.web.filter.HttpPutFormContentFilter</filter-class> 
</filter> 

<filter-mapping> 
    <filter-name>httpPutFormFilter</filter-name> 
    <servlet-name>dispatcherServlet</servlet-name> 
</filter-mapping> 

<servlet> 
    <servlet-name>dispatcherServlet</servlet-name> 
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
</servlet> 
0
<dependency> 
    <groupId>org.apache.tomcat</groupId> 
    <artifactId>tomcat-servlet-api</artifactId> 
    <version>7.0.30</version> 
    <scope>provided</scope> 
</dependency> 

Вы можете решить проблему, добавив обновление версии tomcat-servlet-api.

+0

ОК, большое спасибо! Я проверю его, а затем обновить статус вопроса. – jhek

+0

Ну, я тестировал ... и это не работает :( – jhek

Смежные вопросы