我有一個Spring Web MVC應用程序,我想使用RESTful URL。令人遺憾的是,我還沒有發現任何適用於Tuckey的UrlRewriteFilter的配置。與Tuckey UrlRewriteFilter和Spring 3 Web MVC存在問題
我使用的是「DefaultAnnotationHandlerMapping」,我在我的類路徑中添加了「urlrewritefilter.jsp」,並將「urlrewrite.xml」複製到「/ WEB-INF /」中。
我不想實現xyz://www.domain.com/abc將會被重定向到用戶的不可見的位置:xyz://www.domain.com/app/abc用我的控制器,並讓xyz://www.domain.com/css不變。
我 「的web.xml」 這種方式配置:
<?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>
我 「urlrewrite.xml」 這種方式配置:
<?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>
我AbcController.java對於映射xyz://www.domain.com/abc有這樣的方法:
@RequestMapping(value = "/app/abc", method=RequestMethod.GET)
public void displayRegistration(Model model)
{
...
}
但在嘗試訪問XYZ的時候我總是收到 「HTTP狀態404」://www.domain.com/或XYZ://www.domain.com/abc :-(
這將是非常如果有人能幫上忙,那就很好。
問候
尼
附:由於堆棧溢出垃圾郵件保護,我必須用xyz://替換http://。 * OO * – 2010-09-19 15:45:45