title: How can I map a spring controller to a url with .jsp extension?
body: <p>We are in the process of migrating a jsp-only application to Spring-MVC. For various reasons we can't change the extension of the current pages. (calls to login.jsp need to handled by a spring controller that will use a jsp file as view).</p>
  
  <p>We are doing this iteratively, so some pages need to stay jsp files (calls to welcome.jsp won't be handled by a controller).</p>
  
  <p>To do that I mapped both the DispatcherDervlet and the HandlerMapping to *.jsp, and configured the JstlView in the standard way.</p>
  
  <p>Unfortunately, if I browse to //login.jsp I get an error saying</p>
  
  <pre><code>&lt;No mapping found for HTTP request with URI [/&lt;context&gt;/WEB-INF/jsp/login.jsp] in DispatcherServlet with name 'spring'&gt;
  </code></pre>
  
  <p>It all works if I change .jsp to any other extension in DispatcherServlet and HandlerMapping.</p>
  
  <p>web.xml:</p>
  
  <pre><code>&lt;servlet&gt;
      &lt;servlet-name&gt;spring&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;spring&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.jsp&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>spring-servlet.xml:</p>
  
  <pre><code>&lt;!-- View resolver --&gt;
  &lt;bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver"&gt;
      &lt;property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/&gt;
      &lt;property name="prefix" value="/WEB-INF/jsp/"/&gt;
      &lt;property name="suffix" value=".jsp"/&gt;
  &lt;/bean&gt;
  
  &lt;!-- URL Mapping --&gt;
  &lt;bean id="publicUrlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"&gt;
      &lt;property name="urlMap"&gt;
          &lt;map&gt;
              &lt;entry key="/login.jsp" value-ref="loginController"/&gt;
          &lt;/map&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>Thanks a lot.</p>
  
  <p><em>UPDATE</em>: I just verified that if I rename my .jsp files to something else (.jst) and update the viewResolver accordingly, than it all works. Apparently if the view is resolved to a file with extension .jsp, spring tries to forward the view to another controller.</p>