Struts 2在重定向时删除.action扩展名 [英] Struts 2 remove .action extension when redirect
问题描述
在开始之前,我很抱歉我的英语不好,因为英语不是我的第一语言。但是,我有一个Struts 2重定向问题。
我的Struts.xml文件的一部分是这样的:
Before starting, I'm sorry for my bad English, because English is not my first language. However, I have a problem with Struts 2 redirecting.
One part of my Struts.xml file is like this:
<package name="login" namespace="/" extends="struts-default">
<action name="login" class="Action.loginAction">
<result name="success" type="redirectAction">
<param name="actionName">search</param>
<param name="namespace">/</param>
</result>
<result name="error">/login.jsp</result>
<result name="input">/login.jsp</result>
</action>
</package>
我有一个loginAction负责登录用户(无论这个文件的内容是什么)。当此操作的结果成功时,我想重定向到搜索操作。一切正常,但我的问题是,当我重定向到搜索操作时,URL看起来像这样:http:// localhost:8080 / MyWebApplication / search.action
我想在重定向到特定操作时从URL中删除.action。我需要更改什么来解决这个问题?
感谢您的关注。
I have a loginAction that's responsible for logging in the user (no matter what is the content of this file). When the result of this action is success, I want to redirect to search action. Everything works fine, but my problem is, when I redirect to search action, the URL looks like this: http://localhost:8080/MyWebApplication/search.action
I want to have the .action removed from the URL, when redirecting to a particular action. What do I need to change to fix this?
Thanks for your attention.
推荐答案
试试这个....
Try this....
<struts>
<constant name="struts.action.extension" value="" />
</struts>
这篇关于Struts 2在重定向时删除.action扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!