0

I have the following problem: Whenever I try to edit the following data, I get an exception saying that HTTP PUT is not supported by this URL. This is the JSP form side of things where a button is used to edit that row:

<c:url var="formAction" value="/circuits/${circuit.circuitId}" /> <form:form method="PUT" action="${formAction}"> <input type="hidden" name="circuitId" value="${circuit.circuitId}" /> <input type="submit" value="Edit" class="btn btn-primary" /> </form:form> 

And the following is my controller method that retrieves the circuitId:

@RequestMapping(value = "/{circuitId}", method = RequestMethod.PUT) public String showEditCircuitForm(@PathVariable Integer circuitId, ModelMap model) throws NoSuchRequestHandlingMethodException 

However, when I use the normal GET method everything works fine, it's just this PUT method that is causing the problem. I have got all the dependencies that I need.

1
  • remove the hidden field Commented Jul 4, 2013 at 15:54

1 Answer 1

2

Only getand post are officialy supported with forms. I'm not aware of any browser that supports put with forms. It is supported with AJAX, though.

Apart from that the support of the Java Servlet API for PUT is not ideal. You might need to include a filter in your web.xml:

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

Before I forget: You can send a post request and use another filter to fake a put request:

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

To get this working you have to include a hidden field with the name _method and the value PUT in your form.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.