Struts2 +是 6.1 + JavaEE
这个“struts.xml”:
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="false" />
<package name="register" namespace="/" extends="struts-default">
<action name="Register" class="com.struts2.RegisterAction">
<result name="input">/register.jsp</result>
<result type="redirectAction">register.jsp</result>
</action>
</package>
在 Tomcat 中工作得很好,但在 WAS 6.1 中总是生成以下错误:
“没有为命名空间/和操作名称映射操作。-[未知位置]”
但是如果我像下面这样修改“struts.xml”,那么它工作正常在 WAS6.1 中:
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="false" />
<package name="register" namespace="/register" extends="struts-default">
<action name="Register" class="com.struts2.RegisterAction">
<result name="input">/register.jsp</result>
<result type="redirectAction">register.jsp</result>
</action>
</package>
<package name="default" namespace="/" extends="struts-default">
<default-action-ref name="index" />
<action name="index">
<result type="redirectAction">
<param name="actionName">Register</param>
<param name="namespace">/register</param>
</result>
</action>
</package>
我完全不明白这是什么原因。它总是在寻找我相信的操作名称“index”。谁能解释一下原因是什么?
This "struts.xml":
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="false" />
<package name="register" namespace="/" extends="struts-default">
<action name="Register" class="com.struts2.RegisterAction">
<result name="input">/register.jsp</result>
<result type="redirectAction">register.jsp</result>
</action>
</package>
Works perfectly fine in Tomcat but always generates following error always in WAS 6.1:
" There is no Action mapped for namespace / and action name . - [unknown location]"
But if I modify the "struts.xml" like following then it works fine in WAS6.1:
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="false" />
<package name="register" namespace="/register" extends="struts-default">
<action name="Register" class="com.struts2.RegisterAction">
<result name="input">/register.jsp</result>
<result type="redirectAction">register.jsp</result>
</action>
</package>
<package name="default" namespace="/" extends="struts-default">
<default-action-ref name="index" />
<action name="index">
<result type="redirectAction">
<param name="actionName">Register</param>
<param name="namespace">/register</param>
</result>
</action>
</package>
I totally can't understand what is the reason. It's always looking for I believe the action name "index". Can anyone explain what the reason is?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定这是否是问题的原因,但我看不到您在 struts.xml 中定义了一个名为“register.jsp”的操作。结果类型“redirectAction”用于定位 struts2 操作。输入时您没有指定类型,因此默认为“调度程序”。
更改:
其中
假定请求类型为“dispatcher”(jsp),名称为“success”。
I am not sure if this is the cause of the issue but I can't see where you have defined an action in your struts.xml called "register.jsp". The result type "redirectAction" is used to target a struts2 action. On input you do not specify a type so the default is assumed which is "dispatcher".
Change:
with
Which assumes the request type is "dispatcher" (a jsp) and the name is "success".