0
我有一个Struts 2应用程序。我们正在吸引很多用户访问index.html网址。我想重新定向它们。我的想法是从URL中删除'index.html'并重定向到该目录(即example.com/some/dir/index.html => example.com/some/dir/)。重定向index.html
我猜在struts.xml中有这样做的简单方法。
我有一个Struts 2应用程序。我们正在吸引很多用户访问index.html网址。我想重新定向它们。我的想法是从URL中删除'index.html'并重定向到该目录(即example.com/some/dir/index.html => example.com/some/dir/)。重定向index.html
我猜在struts.xml中有这样做的简单方法。
我不确定你在找什么,但它听起来像你想要一个默认行动的解决方案?或者一个欢迎文件设置?
<package name="restful" extends="struts-default">
<!-- YOUR ACTIONS HERE -->
<default-action-ref name="default" />
<action name="default">
<result type="redirectAction">home</result>
</action>
</package>
或
<package name="restful" extends="struts-default">
<!-- YOUR ACTIONS HERE -->
<default-action-ref name="default" />
<action name="default">
<result type="redirect">index.jsp</result>
</action>
</package>
或在你的web.xml我已经能够设定为欢迎文件的操作:
<welcome-file-list>
<welcome-file>home</welcome-file>
</welcome-file-list>
什么是这样做的目的是什么?我不确定你想要什么,但是你可以创建一个名为index.html的动作,然后你可以使用forward,链接任何内容,但不会改变URL。如果你想在一致的基础上做到这一点,那么URL重写可能是一个更好的解决方案,在Linux上我会使用iptables,在Apache mod重写...有很多选项,只是谷歌网址重写,并决定是否那就是你想要的。 – Quaternion 2011-04-27 18:30:46