I have a Spring MVC app with various methods annotated by for example
@RequestMapping(value="/SomeUrl/{filename:.+}", method=RequestMethod.GET)
In the majority of cases this works perfectly fine; the ".+" regex means filenames containing a dot character with an extension also work fine (as described here Spring MVC @PathVariable getting truncated )
However if the request is "/SomeUrl/Something.jsp", then the request never even hits my method, presumably because Spring MVC has built in processing that notices that the extension is .jsp and then searches for an actual file called Something.jsp.
My app does have JSPs, but they are all accessed via @RequestMapping methods or servlets, the JSPs are never accessed directly. So how can I disable Spring MVC from performing any special processing with the .jsp extension?
FYI in my web.xml I pipe everything into the MVC dispatcher like so:
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
dispatcher-servlet.xml contains the following:
<mvc:annotation-driven content-negotiation-manager="contentNegotiationManager"/>
<bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
<!-- Turn off working out content type based on URL file extension, should fall back to looking at the Accept headers -->
<property name="favorPathExtension" value="false" />
</bean>
<!-- This allows the static content (the CSS file) to be accessed still via the dispatcher -->
<mvc:resources mapping="/resources/**" location="/resources/" />
<context:component-scan base-package="com.myservicepackage" />
Many thanks for any suggestions on this!