Reputation: 1124
1) Is there a way to integrate UrlRewritingFilter with Struts2 tiles.i think there is a problem with listeners in web xml.
<listener>
<listener-class>listener.ApplicationListener</listener-class>
</listener>
<listener>
<listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
</listener>
2) how to use struts2 advanced wildcard mapping to write better urls with actions.anybody can share a working example please?
thanks.!!
Upvotes: 0
Views: 2101
Reputation: 23587
This is how you need to configure your rewrite filter
<filter>
<filter-name>UrlRewriteFilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
<init-param>
<param-name>logLevel</param-name>
<param-value>WARN</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
Please note the change done to S2 filter
Add a rewrite.xml
file under WEB-INF
with entry like
<urlrewrite>
<rule>
<from>^/some/olddir/(.*)$</from>
<to type="redirect">/very/newdir/$1</to>
</rule>
</urlrewrite>
For more details refer to there documents.
There is one more option to create clean URL using NamedVariablePatternMatcher
,for details refer to this blog for example and understanding
Upvotes: 1