J2EE Servlet 명세에서 인코딩된(content type : application/x-www-form-urlencoded) HTTP PUT 메소드는 지원하지 않기 때문에 폼에 값을 담은 후 PUT으로 서버에 전송할 경우 Command Object 바인딩이 자동으로 되지 않는다.


해결책은 아래와 같다. 


자료 찾느라 열라 고생함 ㅠㅠ 

(아직 spring 기반의 RESTful 서비스가 많지 않아서 그런가? 아님 너무 당연해서 나만 몰랐던 건가?)


출처 : http://static.springsource.org/spring/docs/current/spring-framework-reference/html/mvc.html

16.3.3.11 Working with "application/x-www-form-urlencoded" data

The previous sections covered use of @ModelAttribute to support form submission requests from browser clients. The same annotation is recommended for use with requests from non-browser clients as well. However there is one notable difference when it comes to working with HTTP PUT requests. Browsers can submit form data via HTTP GET or HTTP POST. Non-browser clients can also submit forms viaHTTP PUT. This presents a challenge because the Servlet specification requires the ServletRequest.getParameter*() family of methods to support form field access only for HTTP POST, not for HTTP PUT.

To support HTTP PUT requests, the spring-web module provides the filter HttpPutFormContentFilter, which can be configured in 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>

The above filter intercepts HTTP PUT requests with content type application/x-www-form-urlencoded, reads the form data from the body of the request, and wraps the ServletRequest in order to make the form data available through the ServletRequest.getParameter*() family of methods.


참고 : http://static.springsource.org/spring/docs/3.1.x/javadoc-api/org/springframework/web/filter/HttpPutFormContentFilter.html




+ Recent posts