请教大家一个问题,在struts2中,我要在一个index.jsp页面中,调用2个Action,并将这两个Action的返回值显示出来要怎么处理?

解决方案 »

  1.   

    不可能细说一下你的需求good luck
      

  2.   

    index.jsp<%@ taglib prefix="s" uri="/struts-tags"%>
    <html>
    <head>
    <title>Untitled</title>
    </head>
    <body>
    <s:action name="请求1" namespace="请求1所在命名空间" executeResult="true"></s:action>
    <s:action name="请求2" namespace="请求2所在命名空间" executeResult="true"></s:action>
    </body>
    </html>
      

  3.   

    redlotus_lyn,我的jsp页面调用如下:
        <ul>
    <s:action id="PubInfoList" name="PubInfoList" namespace="/com.govinfo.action" executeResult="true"/>
        <s:iterator value="#request.PubInfoList">
          <li><s:property value="PubInfoTitle"/></li>
        </s:iterator>     
        </ul>Action的代码如下:/**
     * 
     */
    package com.govinfo.action;import java.util.Collection;import org.apache.struts2.ServletActionContext;import com.govinfo.core.BaseAction;
    import com.govinfo.dao.PubInfo;
    /**
     * @author Administrator
     *
     */
    public class PubInfoAction extends BaseAction{
    /**
     * 
     */
    private static final long serialVersionUID = -1820436491061614295L;
    private PubInfo dao = PubInfo.getInstance(); 
    private Collection<com.govinfo.Entity.PubInfo> PubInfoList;

    /**
     * @return the PubInfoList
     */
    public Collection<com.govinfo.Entity.PubInfo> getPubInfoList() throws Exception {
    return PubInfoList;
    } /**
     * @param PubInfoList the PubInfoList to set
     */
    public void setPubInfoList(Collection<com.govinfo.Entity.PubInfo> PubInfoList) {
    this.PubInfoList = PubInfoList;
    }
    public String list() throws Exception{
    PubInfoList = dao.FastFindAll();
    ServletActionContext.getRequest().setAttribute("PubInfoList", PubInfoList);
    return SUCCESS;
    }
    }
      

  4.   

    <s:action name="student_findAll" executeResult="true"></s:action>写2个<s:action >就行了   这个标签相当于把你action跳到的页面整个copy过来你当前的前面
      

  5.   

    解决说明:和executeResult无关,主要是要在struts.xml进行配置,并且不能有跳转【这个很重要】:
    <struts>  
          <package name="GovInfo" extends="struts-default">     
    <action name="PubInfoList" class="com.govinfo.action.PubInfoAction" method="list"/>

          </package>
     </struts>
    ==================================================================
    jsp页面调用:
    <s:action id="PubInfoList" name="PubInfoList">
        <s:iterator value="#request.PubInfoList">
          <li><s:property value="PubInfoTitle"/></li>
        </s:iterator>