重定向index.html

时间:2011-04-27 17:39:08

标签: redirect struts2

我有一个Struts 2应用程序。我们让很多用户访问index.html网址。我想重定向它们。我的想法是从URL中删除'index.html'并重定向到该目录(例如:example.com/some/dir/index.html => example.com/some/dir /)。

我猜测在struts.xml中有一种简单的方法。

1 个答案:

答案 0 :(得分:0)

我不确定你在寻找什么,但听起来你想要一个默认动作的解决方案呢?或者欢迎文件设置?

<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>
相关问题