如何自动添加struts动作后缀

时间:2013-10-18 08:06:31

标签: java struts2

我修改了struts.xml以使用.htm进行所有操作。

<package name="home" namespace="/secured" extends="default">
    <default-action-ref name="index" />

    <action name="index" class="homeAction" method="execute">
        <result name="success" type="tiles">home</result>
    </action>
</package>

我有一个URL映射 http://someurl/someproject/secured/somesubgroup/actionname.htm

但是,如果我拨打http://someurl/someproject/securedhttp://someurl/someproject/secured/somesubgroup,我会收到404错误。如果我将.htm添加到网址,我就不会遇到任何问题。

我已为/secured/somesubgroup/secured命名空间定义了默认操作,希望当我只调用上面的URL时,将调用默认操作。

现在,如何自动添加.htm?或者有没有解决方法呢?

编辑:

这是struts.xml

<struts>
    <constant name="struts.enable.DynamicMethodInvocation" value="false"/>
    <constant name="struts.action.extension" value="htm" />
    <constant name="struts.objectFactory" value="spring" />  
    <constant name="struts.devMode" value="true"/>

    ...
</struts>

1 个答案:

答案 0 :(得分:1)

为了支持没有操作后缀的操作,您必须声明struts.action.extension不变,如下所示:

<constant name="struts.action.extension" value="htm,," />
相关问题