title: Spring - Rewrite one URL to another
body: <p>I have a Spring 2.5 application that contains a Flash banner.  I don't have the source for the Flash component but it has links hardcoded to certain pages that end in <code>.html</code>  I want to be able to redirect those .html pages to existing jsp pages.  How can I have Spring resolve a few .html pages to .jsp pages?</p>
  
  <p>My project looks like:</p>
  
  <pre><code>WebContent
   |
   -sample.jsp
   -another.jsp
    WEB-INF
    |
    -myapp-servlet.xml
    -web.xml
  </code></pre>
  
  <p>I want <code>localhost:8080/offers.html</code> to redirect to <code>localhost:8080/sample.jsp</code></p>
  
  <p>Can I do this with Spring?  I already have a SimpleUrlHandlerMapping and UrlFilenameViewController defined in the myapp-servlet.xml that has to continue serving the pages it already is.  </p>
  
  <p>In my web.xml, I have</p>
  
  <pre><code>&lt;servlet-mapping&gt;
    &lt;servlet-name&gt;myapp&lt;/servlet-name&gt;
    &lt;url-pattern&gt;*.htm&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p><strong>Update</strong></p>
  
  <p>Here is the URL mapper.  If I add a controller, how do I return the jsp view that is in the WebContent directory as the view resolver includes the /WEB-INF/jsp directory.</p>
  
  <pre><code>&lt;bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"&gt;
    &lt;property name="mappings"&gt;
      &lt;props&gt;
        &lt;prop key="/page1.htm"&gt;page1Controller&lt;/prop&gt;
        &lt;prop key="/page2.htm"&gt;page2Controller&lt;/prop&gt;
      &lt;/props&gt;
    &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"&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;
  </code></pre>