给个最原始方法action :request.setAttribute("cityname","shanghai");
jsp    :<%=request.getAttribute("cityname")%>struts2中有比较好的方法

解决方案 »

  1.   

    查詢出所有學校放到list
    request.setAttribute("school",schoollist);
    葉面再用 
    list = request.getAttribute("school")
      

  2.   

    在页面中不出现Java代码,用struts2来实现,高手们给点办法吧!!
      

  3.   

    放入list之中然后request.set...() 在用logic:iterate显示
      

  4.   

    /**
     * @author Nicholas
     */
    var req;
    function Change_Select() {
    var cid = document.getElementById("countyid").value;
    var url = "./select?cid=" + cid;
    if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
    } else {
    if (window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLHTTP");
    }
    }
    if (req) {
    req.open("GET", url, true);
        
    req.onreadystatechange = callback;
    req.send(null);
    }
    }function callback() {
    if (req.readyState == 4) {
    if (req.status == 200) {
    parseMessage();
    } else {
    alert("无法得到描述信息:" + req.statusText);
    }
    }
    }
        //½âÎö·µ»ØxmlµÄ·½·¨
    function parseMessage() {
    var xmlDoc = req.responseXML.documentElement;
    var xSel = xmlDoc.getElementsByTagName("select");
           var street = document.getElementById("street.streetid");
         street.options.length = 0;
         
    for (var i = 0; i < xSel.length; i++) {
    var xText = xSel[i].childNodes[0].firstChild.nodeValue; var xValue = xSel[i].childNodes[1].firstChild.nodeValue;
      
    var option = new Option(xText, xValue);
          
    try {
    street.add(option);
    }
    catch (e) {
    }
    }
    }
      

  5.   


      //Servlet
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException { response.setContentType("text/xml;charset=utf-8");
    PrintWriter out = response.getWriter();
    int cid = Integer.parseInt(request.getParameter("cid")); // 获取区县ID
    IHouseDAO houseDAO = new IHouseDAO();
    List list = houseDAO.getStreetList(cid); // 根据区县ID获取街道信息
    String xmlStart = "<selects>";
    String xmlEnd = "</selects>";
    String xmlDoc = "";
    for (int i = 0; i < list.size(); i++) { Street street = (Street) list.get(i);
    xmlDoc += "<select><text>" + street.getStreetname()
    + "</text><value>" + street.getStreetid()
    + "</value></select>"; }
    String xmlLast = xmlStart + xmlDoc + xmlEnd;
    out.write(xmlLast);
    out.flush();
    out.close();
    }
      

  6.   

    action :request.setAttribute("cityname","shanghai"); 
    jsp    : <%=request.getAttribute("cityname")%> 
    用这个就可以了
      

  7.   

    在action类中(如类名为schoolsquery):
    class schoolsquery {
        private List<School> shools = null;
        private City city = null;
        ......
        public List<School> getSchools(){
            return shools;
        }
        public void setCity(City city){
            this.city=city;
        }
        public City getCity(){
            return city;
        }
        ......
        public String execute(){
            schools = SchoolDao.getSchools(city);//假如这是用城市查找学校的方法
             return "success";
        }
    }
    在jsp中可以直接迭代schools对象:
    <s:iterator value="schools">
    <s:property value="schoolName"/>
    ......
    <br>
    </s:iterator>在上述迭代中,假设School类有一个getschoolName方法。
      

  8.   

    没接触过stucts2,不过如果用hibernate的话你可以用一个多对多关系映射到数据库然后通过stucts1.1来传值或者直接servlet过去.和用户权限原理一样.我的理解
      

  9.   


    用Ajax调用.do方法,参数放在Url里面就可以了..
      

  10.   

    动态级联的操作用AJAX最方便
    也可以用<c:foreach var="x" items="${xx}"></c:foreach>
    或<logic:iterate id="x" name="xx"></logic:iterate>
      

  11.   

    1、在action中取得所有学校的列表xxlist,可以在attribute中返回给页面;
    2、在jsp页面展示信息:
    <table>
         <logic:present name="XXList">
            <logic:iterate id="school" name="XXList">
                <tr> 
            <td><bean:write name="school" property="name" /></td>
                    <td>……</td><!--需要展示的信息-->
                </tr>
            </logic:iterate>
       </logic:present>
    </table>
      

  12.   

    先将您需要的对象存在request中
    action :request.setAttribute("cityname","XXX"); 
    jsp    : <%=request.getAttribute("cityname")%>显示出来
    获得城市以后要获得对应该城市的学校需要遍历
    可以使用c:foreach var="x" items="${xx}"> </c:foreach> 
    或 <logic:iterate id="x" name="xx"> </logic:iterate> 
    这样就可以查找出学校
      

  13.   

    在页面上实用struts2的标签,进行迭代。
    具体做法如下:
    1.从action中取出city对象
    2.然后将city中属性school的集合实用标签迭代就可以了(注意:必须在Hibernate的配置文件配置了一对多的关系)
    具体细节就靠自己写了