web.xml:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
controller method signature:
@RequestMapping(value = {"","/"}, method = RequestMethod.POST)
public ModelAndView index(Model model, @RequestParam("someParam") String someParam)
The problem is that when I hit the root with the trailing slash it works fine, but when I hit the root with no trailing slash, then JBoss (or the browser) is picking up the request, and forwarding it via GET with the trailing slash. I then get the following:
HTTP Status 405 – Request method ‘GET’ not supported
It turns out this was an issue with how Apache and the context for Tomcat was configured. The above works just fine.