title: How to disable processing of JSP URLs in Spring MVC?
body: <p>I have a Spring MVC app with various methods annotated by for example</p>
  
  <pre><code>@RequestMapping(value="/SomeUrl/{filename:.+}", method=RequestMethod.GET)
  </code></pre>
  
  <p>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 <a href="https://stackoverflow.com/questions/3526523/spring-mvc-pathvariable-getting-truncated">Spring MVC @PathVariable getting truncated</a> )</p>
  
  <p>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.</p>
  
  <p>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?</p>
  
  <p>FYI in my web.xml I pipe everything into the MVC dispatcher like so:</p>
  
  <pre><code>&lt;servlet&gt;
      &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>dispatcher-servlet.xml contains the following:</p>
  
  <pre><code>&lt;mvc:annotation-driven content-negotiation-manager="contentNegotiationManager"/&gt;
  
  &lt;bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean"&gt;
      &lt;!-- Turn off working out content type based on URL file extension, should fall back to looking at the Accept headers --&gt;
      &lt;property name="favorPathExtension" value="false" /&gt;
  &lt;/bean&gt;
  
  &lt;!-- This allows the static content (the CSS file) to be accessed still via the dispatcher --&gt;
  &lt;mvc:resources mapping="/resources/**" location="/resources/" /&gt;
  
  &lt;context:component-scan base-package="com.myservicepackage" /&gt;
  </code></pre>
  
  <p>Many thanks for any suggestions on this!</p>