To get the rest interfaces I planned to work in my Spring application were a bit of a headache because I did not do many things correctly.
First thing I was not aware was the changes to the web.xml:
<filter> <filter-name>hiddenHttpMethodFilter</filter-name> <filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class> </filter> <filter-mapping> <filter-name>hiddenHttpMethodFilter</filter-name> <servlet-name>spring</servlet-name> </filter-mapping>
These lines were added right after the DispatcherServlet. Without these lines I was getting errors on the DELETE method saying that the POST method was not implemented.
I also had a lot of trouble trying to generate a dynamic URL for the Rest calls. I could not get code similar to this to work:
<form:form action="<%= formUrl%>" method="delete"> <input type="submit" value="Delete"/> </form:form>
I tried the construct to generate the URL and it would not accept a string concatenated with a property from an object.
I add to declare a variable to do the concatenation:
String formUrl = "/admin/something/" + something.getId();
At least everything is working right now but that is a few hours lost to figuring out what works and why. Coding fun!