Struts2的action url对google与用户都不那么友好,所以对外的网站可以使用url rewrite filter来改善。
见showcase的示例,首先在web.xml中加入url rewrite filter,注意需放到struts2 filter的前面,然后在WEB-INF/下放一个urlrewrite.xml进行定义,使得
/common/users.htm 等于 /common/user.action
/common/user/1.htm 等于 /common/user!input.action?id=1
<urlrewrite>
<rule>
<from>^/common/users.htm$</from>
<to type="forward">/common/user.action</to>
</rule>
<rule>
<from>^/common/user/([0-9]+)/.htm$</from>
<to type="forward">/common/user!input.action?id=$1</to>
</rule>
</urlrewrite>