当前位置: 代码迷 >> Java Web开发 >> struts2 action间传参,该如何解决
  详细解决方案

struts2 action间传参,该如何解决

热度:251   发布时间:2016-04-12 22:41:31.0
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;
}


测试了下,没问题
页面显示了这个参数,希望对你有用
  相关解决方案