views:

143

answers:

1

Hi, I have a Spring Web MVC application and I want to use RESTful URLs. Regrettably I haven't found any configuration that works for me with Tuckey's UrlRewriteFilter.

I'm using the "DefaultAnnotationHandlerMapping" and I added "urlrewritefilter.jsp" to my classpath and copied "urlrewrite.xml" into "/WEB-INF/".

I wan't to achieve that xyz://www.domain.com/abc will be redirected (invisible for the user) to xyz://www.domain.com/app/abc to catch it with my Controller and to let xyz://www.domain.com/css untouched.

My "web.xml" is configured this way:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="xyz://java.sun.com/xml/ns/javaee" xmlns:xsi="xyz://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="xyz://java.sun.com/xml/ns/javaee xyz://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

 <!-- Context -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/applicationContext.xml
            /WEB-INF/applicationContext-security.xml
        </param-value>
    </context-param>

 <!-- Context Loader -->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <!-- Spring Security -->
    <filter>
      <filter-name>springSecurityFilterChain</filter-name>
      <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>
    <filter-mapping>
      <filter-name>springSecurityFilterChain</filter-name>
      <url-pattern>/*</url-pattern>
    </filter-mapping>

 <!-- Tuckey UrlRewriteFilter -->
 <filter>
  <filter-name>UrlRewriteFilter</filter-name>
  <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
 </filter>
 <filter-mapping>
  <filter-name>UrlRewriteFilter</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>

 <!-- Dispatcher Servlet -->
    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>2</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
  <url-pattern>/app/*</url-pattern>
    </servlet-mapping>

 <!-- All the rest... -->
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>redirect.jsp</welcome-file>
    </welcome-file-list>
</web-app>

My "urlrewrite.xml" is configured this way:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 3.2//EN"
        "xyz://tuckey.org/res/dtds/urlrewrite3.2.dtd">

<urlrewrite default-match-type="wildcard">
 <rule>
  <from>/**</from>
  <to>/app/$1</to>
 </rule>
 <outbound-rule>
  <from>/app/**</from>
  <to>/$1</to>
 </outbound-rule>
</urlrewrite>

My AbcController.java for mapping xyz://www.domain.com/abc has such methods:

@RequestMapping(value = "/app/abc", method=RequestMethod.GET)
public void displayRegistration(Model model)
{
 ...
}

But I always receive "HTTP Status 404" when trying to access xyz://www.domain.com/ or xyz://www.domain.com/abc :-(

It would be very nice if somebody could help.

Greetings

Benny

A: 

Did you try with

@RequestMapping(value = "/abc", method=RequestMethod.GET)
Raghuram