黑马程序员技术交流社区

标题: 关于Struts2中向result传值的问题!!? [打印本页]

作者: 小斥候    时间: 2014-7-23 19:33
标题: 关于Struts2中向result传值的问题!!?
Action的一个方法返回值为“success”,想向对应的result传递参数,用来组成URL,
比如<result name="success" type="redirectAction">user_list.action?(参数)</result>


----------------->>求助!!!!!!!!!!!!!!!!!!!!

作者: 莫问纷飞    时间: 2014-7-23 19:43
假如你想传的是用户名username
ActionContext.getContext().put("username",username);往map栈里放
<result name="success" type="redirectAction">user_list?username=${#username}</result>
action里面必须用属性驱动或模型驱动来接收了

话说你们oa是谁讲的,老师写完不都把代码给你们吗?
标签内写的action地址就不用加.action后缀了
再有你重定向到用户列表为什么要传参数。。搞不懂
作者: 小斥候    时间: 2014-7-23 20:07
莫问纷飞 发表于 2014-7-23 19:43
假如你想传的是用户名username
ActionContext.getContext().put("username",username);往map栈里放
user_li ...

我自学的。。。。
话说<result name="toList" type="redirectAction">${id}
这样总是获取不到
我把redirectAction换成redirect后就行了,这是为什么?
作者: 小斥候    时间: 2014-7-23 20:19
莫问纷飞 发表于 2014-7-23 19:43
假如你想传的是用户名username
ActionContext.getContext().put("username",username);往map栈里放
user_li ...

就连问号 ?id= 都没有




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2