Struts2链接默认对应Action扩展名和更改
Struts2中的链接默认对应linkAction.action中的linkAction.
Action login 的访问链接可以是 http://localhost:8080/context/login,也可以是http://localhost:8080/context/login.action.
这个默认的扩展名可以修改:
1.
Action login 的访问链接可以是 http://localhost:8080/context/login,也可以是http://localhost:8080/context/login.do。
Struts2中的链接默认对应linkAction.action中的linkAction.
在struts.xml中:
<struts>
<package name="default" extends="struts-default">
<action name="login" class="com.cc.login.LoginAction">
<result name="success">
/result.jsp
</result>
</action>
</package>
</struts>
Action login 的访问链接可以是 http://localhost:8080/context/login,也可以是http://localhost:8080/context/login.action.
这个默认的扩展名可以修改:
1.
<struts>
<constant name="struts.action.extension" value="do"/>
<package name="default" extends="struts-default">
<action name="login" class="com.cc.login.LoginAction">
<result name="success">
/result.jsp
</result>
</action>
</package>
</struts>
2.给struts过滤器添加初始化参数:
<init-param>
<param-name>struts.action.extension</param-name>
<param-value>do</param-value>
</init-param>
Action login 的访问链接可以是 http://localhost:8080/context/login,也可以是http://localhost:8080/context/login.do。