s:param用法

Leeds201224 2010-09-05 01:45:03
在jsp页面是<s:action name="createMenuRoot" id="createMenuRoot">
<s:param name="flag" value="'0'"></s:param>
<s:param name="roleCode" value="'s001'"></s:param>
</s:action>

在action中String flag = ServletActionContext.getRequest().getAttribute("flag").toString();
String ss= ServletActionContext.getRequest().getAttribute("roleCode").toString();
却获取不到roleCode参数的值,怎么才能获取2个参数值,在线等!
...全文
658 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
moseand1 2012-05-21
  • 打赏
  • 举报
回复
lz说下是什么原因导致的呗? 使用<s:param name="XX" value="object"> 标签这种用法,value是以object的形式压入stack的,在action中肯定得用getAttribute()方法获取吧! 是怎么解决的呢?
redlotus_lyn 2010-09-06
  • 打赏
  • 举报
回复
在createMenuRoot请求对应的Action中定义flag和roleCode变量并有get/set方法,框架会自动传过去。
Leeds201224 2010-09-06
  • 打赏
  • 举报
回复
param传递参数,必须以getAttribute来获取值,用getParameter根本无法获取值
redlotus_lyn 2010-09-06
  • 打赏
  • 举报
回复
<s:action name="createMenuRoot" id="createMenuRoot">
<s:param name="flag" value="'0'"></s:param>
<s:param name="roleCode" value="'s001'"></s:param>
</s:action

createMenuRoot是请求,如果传递参数,参数会加在请求的后面

在Action中取得请求中的参数,必须用getParameter

String flag = ServletActionContext.getRequest().getParameter("flag").toString();
Leeds201224 2010-09-06
  • 打赏
  • 举报
回复
好了,我知道原因,谢谢redlotus_lyn帮忙
Leeds201224 2010-09-06
  • 打赏
  • 举报
回复
在action中定义flag和roleCode属性,并设置get/set方法,这个传递参数,我会!
我想知道ServletActionContext.getRequest().getAttribute("flag").toString();
能获取flag参数值,为什么ServletActionContext.getRequest().getAttribute("roleCode").toString();就不能获取roleCode参数值!!!
Leeds201224 2010-09-05
  • 打赏
  • 举报
回复
action只能获取flag参数值,而无法获取roleCode参数的值
penweizgx002 2010-09-05
  • 打赏
  • 举报
回复
我看大部分是配合其他标签使用的。
Leeds201224 2010-09-05
  • 打赏
  • 举报
回复
去掉单引号,那不是变量么
changmengmeng 2010-09-05
  • 打赏
  • 举报
回复
单引号去了试试看,提示什么错误?
Leeds201224 2010-09-05
  • 打赏
  • 举报
回复
单引号没有问题,用getParameter返回的是null,用s:param传值必须用getAttribute函数才行
亲努力啊 2010-09-05
  • 打赏
  • 举报
回复
getParameter
thegodofwar 2010-09-05
  • 打赏
  • 举报
回复
看看是不是你的那个单引号写成了中文格式的....

81,092

社区成员

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

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