Spring - rewrite one URL to another

I have a Spring 2.5 application containing a Flash banner. I do not have a source for the Flash component, but it has links that are rigidly attached to certain pages ending in .html. I want to redirect these .html pages to existing jsp pages. How can I allow Spring .html pages to allow .jsp pages?

My project looks like this:

WebContent
 |
 -sample.jsp
 -another.jsp
  WEB-INF
  |
  -myapp-servlet.xml
  -web.xml

I want to be localhost:8080/offers.htmlredirected tolocalhost:8080/sample.jsp

Can I do this with Spring? I already have SimpleUrlHandlerMapping and UrlFilenameViewController defined in myapp-servlet.xml, which should continue to serve the pages that it already has.

In my web.xml I have

<servlet-mapping>
  <servlet-name>myapp</servlet-name>
  <url-pattern>*.htm</url-pattern>
</servlet-mapping>

Update

URL-. , jsp, WebContent, /WEB -INF/jsp.

<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
  <property name="mappings">
    <props>
      <prop key="/page1.htm">page1Controller</prop>
      <prop key="/page2.htm">page2Controller</prop>
    </props>
  </property>
</bean>

<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
  <property name="prefix" value="/WEB-INF/jsp/" />
  <property name="suffix" value=".jsp" />
</bean>
+5
3

, URL- , tuckey.org. SpringSource , , Spring Roo , . .

. , , "" , .

web.xml :

<filter>
        <filter-name>UrlRewriteFilter</filter-name>
        <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
</filter>

WEB-INF/urlrewrite.xml :

<rule>
    <from>offers.html</from>
    <to>offers.jsp</to>     
</rule>
+16

OCPsoft PrettyFaces OCPsoft Rewrite :

PrettyFaces:

WEB-INF/pretty-config.xml

<url-mapping>
   <pattern value="/offers.html" />
   <view-id value="/offers.jsp" />
</url-mapping>

Rewrite:

ConfigurationBuilder.begin()
   .addRule(Join.path("/offers.html").to("/offers.jsp"));

, .

~ Lincoln

+5

-, , "", "". HTTP .

SO, , , :

  • JSP WebContent /WEB-INF/jsp/? ViewResolver.

  • , - ../../another.jsp , /WEB-INF/jsp/../../another.jsp /another.jsp.

  • ViewResolver , . , View , a JstlView. JSP, . View.

  • prefix . , , , /WEB-INF/jsp/. JSP WebContent .

+1

All Articles