struts2中的页面间动态数据传递问题

usb00fa 2010-05-15 11:13:50
在struts1中不能动态的传递数据,如果想动态传递的话,就只有在Action类中的execute方法用foward转发,在struts-config.xml文件中不能配置(例如truts-config.xml文件:不能写path=/next.do?id=表达式),这是struts1的一个硬伤

我想知道的是在struts2中这个问题是怎么解决的(听说可以解决,但是我看了看网上的一些视频,都没有提到这一点),承蒙指点,不知道如何解决

谢谢了
...全文
59 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
junnef 2010-05-15
  • 打赏
  • 举报
回复
struts2中的result type类型描述
<result-types>

<result-type name="chain" class="com.opensymphony.xwork2.ActionChainResult"/>

<result-type name="dispatcher" class="org.apache.struts2.dispatcher.ServletDispatcherResult" default="true"/>

<result-type name="freemarker" class="org.apache.struts2.views.freemarker.FreemarkerResult"/>

<result-type name="httpheader" class="org.apache.struts2.dispatcher.HttpHeaderResult"/>

<result-type name="redirect" class="org.apache.struts2.dispatcher.ServletRedirectResult"/>

<result-type name="redirectAction" class="org.apache.struts2.dispatcher.ServletActionRedirectResult"/>

<result-type name="stream" class="org.apache.struts2.dispatcher.StreamResult"/>

<result-type name="velocity" class="org.apache.struts2.dispatcher.VelocityResult"/>

<result-type name="xslt" class="org.apache.struts2.views.xslt.XSLTResult"/>

<result-type name="plainText" class="org.apache.struts2.dispatcher.PlainTextResult" />

<!-- Deprecated name form scheduled for removal in Struts 2.1.0. The camelCase versions are preferred. See ww-1707 -->

<result-type name="redirect-action" class="org.apache.struts2.dispatcher.ServletActionRedirectResult"/>

<result-type name="plaintext" class="org.apache.struts2.dispatcher.PlainTextResult" />

</result-types>

默认为dispatcher,是action返回后,会把相应的值传递到jsp页面中,比较常用的。
如果需要在action到action之间传递,就是用chain。
而使用redirect则会使传递的信息丢失,具体可以看各个实现类的代码。
crazylaa 2010-05-15
  • 打赏
  • 举报
回复
嗯,楼主搜索:
struts2 result type redirectAction

struts2 result type chain

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧