读取表单 bean 属性以传递给转发
我使用的是struts 1.3。我有一个在 3 种不同情况下重复使用的操作。支持此功能的表单 bean 有一个属性,该属性具有完整路径(从 jsp 传递),在成功/失败的情况下操作应转发到该路径(每种情况的路径都不同,具体取决于用户正在执行的操作)。如何为 struts 配置中的操作的输入属性指定此属性以从该表单 bean 属性中读取。
I am using struts 1.3. I have a an action I am reusing in 3 different cases. The form bean backing this has a property that has the complete path(passed from the jsp) to which the action should forward in case of success/failure(the path is different for each case depending on what the user is doing). How do I specify this for the input attribute of the action in the struts config to read from that form bean property.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以做的是从
Action
类返回动态ActionForward
。这允许您使用struts-config.xml
中未定义的ActionForward
这对您的输入没有帮助,它需要
JSP< /code> 而不是
ActionForward
,但您应该能够在ActionForm
的validate()
方法中执行此操作。传递到该方法的第一个参数是 ActionMapping。在该对象上,您应该能够使用JSP
的路径调用setInput(String)
。我还没有尝试过这个,但看起来应该可行。What you can do is return a dynamic
ActionForward
from yourAction
class. This lets you use anActionForward
that isn't defined in yourstruts-config.xml
This doesn't help you for the input, which expects a
JSP
and not anActionForward
, but you should be able to do that in theActionForm
'svalidate()
method. The first parameter passed into that method is anActionMapping
. On that object, you should be able to callsetInput(String)
with the path of yourJSP
. I have not tried this, but it looks like it should work.