首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

struts2 action间传参,该如何解决

2013-07-11 
struts2action间传参在两个action间传值的时候,action1传的是一个字符串类型的参数,action2接收参数的是一

struts2 action间传参
在两个action间传值的时候,action1传的是一个字符串类型的参数,action2接收参数的是一个对象中的一个属性,跳转方式是chain,求教这样传值要怎样写? Struts action 传参
[解决办法]


                <action name="passParam" class="productStroageAction">
<result type="redirectAction">
  <param name="actionName">findTopics</param>
  <param name="topicName">${topicName}</param>
</result>
</action>
<action name="findTopics" class="productStroageAction" method="findTopics">
<result name="success">/stroage/add.jsp</result>
</action>



        public void passParam(){
topicName = request.getParameter("topicName");
}

        public String findTopics(){
request.setAttribute("message", topicName);
return "success";



         private String topicName;

/**
 * @return the topicName
 */
public String getTopicName() {
return topicName;
}

/**
 * @param topicName the topicName to set
 */
public void setTopicName(String topicName) {
this.topicName = topicName;
}


测试了下,没问题
页面显示了这个参数,希望对你有用

热点排行