在页面上我是这样的:
<logic:iterate name="beanlist" id="editlist">
  <tr>
    <td><bean:write name="editlist" property="name"</td>
    <td><bean:write name="editlist" property="sex"</td>
    <td><bean:write name="editlist" property="city"</td>
 </tr>
  </logic:iterate>
但是不能实现。为什么啊??

解决方案 »

  1.   

    你在jsp文件开始的时候有没有引用struts的标签库呀?
    <@ taglib......
      

  2.   

    有啊!就是<%@ taglib uri="/WEB-INF/tld/struts-logic.tld" prefix="logic" %>撒!
      

  3.   

    <logic:iterate name="beanlist" id="editlist" type="java.util.Collection">
      

  4.   

    还是不行啊!错误是:[ServletException in:/editlist.jsp] Cannot find bean beanlist in any scope'
      

  5.   

    Action的代码:
    package com.xuhua.feedback;import org.apache.struts.action.*;
    import java.util.*;
    import javax.servlet.http.*;
    import com.xuhua.system.User;
    import javax.sql.DataSource;
    import java.sql.SQLException;
    public class feedbackAction extends Action {
      public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception {
        /**@todo: complete the business logic here, this is just a skeleton.*/
        backActionForm back = (backActionForm) actionForm;
        DataSource ds = getDataSource(request,"conPool");
        backBean feed = new backBean(ds);
        Collection c=new ArrayList();
        String id=request.getParameter("id");
        try{
          if(id!=null&&id.equals("find")){
             c=feed.queryback();
             request.setAttribute("beanlist",c);
            }
       }catch(SQLException e){
         System.out.print(e);
       }
       return null;
      }
    }jsp的代码:<%@ page contentType="text/html; charset=GB2312" %>
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
    <%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
    <html>
    <head>
    <title>
    editlist
    </title>
    </head>
    <body>
    <table>
    <logic:iterate name="beanlist" id="editlist">
      <tr>
        <td><bean:write name="editlist" property="name"</td>
        <td><bean:write name="editlist" property="sex"</td>
        <td><bean:write name="editlist" property="city"</td>
     </tr>
      </logic:iterate>
    </table>
    </body>
    </html>
      

  6.   

    Cannot find bean beanlist in any scope?检查一下你的Action配置的是否有问题呀?怎么提示找不到那!
      

  7.   

    我把Action的代码改了一下还是不行啊:
    package com.xuhua.feedback;import org.apache.struts.action.*;
    import java.util.*;
    import javax.servlet.http.*;
    import com.xuhua.system.User;
    import javax.sql.DataSource;
    import java.sql.SQLException;
    public class feedbackAction extends Action {
      public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception {
        /**@todo: complete the business logic here, this is just a skeleton.*/
        backActionForm back = (backActionForm) actionForm;
        DataSource ds = getDataSource(request,"conPool");
        backBean feed = new backBean(ds);
        Collection c=new ArrayList();
        String id=request.getParameter("id");
        try{
          if(id!=null&&id.equals("find")){
             c=feed.queryback();
             request.setAttribute("beanlist",c);
            }
       }catch(SQLException e){
         System.out.print(e);
       }
       return actionMapping.findForward("success");
      }
    }
      

  8.   

    上面是你的源码吗?<bean:write>标签根本没封死呀!
      

  9.   

    不好意思哦!我烤掉了。在我的jsp 中是对的<bean:write name="editlist" property="name"/>
      

  10.   

    我的jsp的代码也改了还是不行错误仍然是:[ServletException in:/editlist.jsp] Cannot find bean beanlist in any scope:<%@ page contentType="text/html; charset=GB2312" %>
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
    <%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
    <html>
    <head>
    <title>
    editlist
    </title>
    </head>
    <body>
    <table>
    <logic:iterate name="beanlist" id="editlist" type="java.util.ArrayList">
      <tr>
        <td><bean:write name="editlist" property="name"/></td>
        <td><bean:write name="editlist" property="sex"/></td>
        <td><bean:write name="editlist" property="city"/></td>
     </tr>
      </logic:iterate>
    </table>
    </body>
    </html>
      

  11.   

    你是如何访问你的jsp的,把你的url帖出来
      

  12.   

    我估计是action,javabean的配置问题。没有配对。
      

  13.   

    在struts-config.xml中转发啊!
     <action-mappings>
       <action name="backActionForm"
               type="feedbackAction"
               validate="true"
               scope="request"
               path="/feedbackAction">
            <forward name="success"
                 path="/edit.jsp"
                 redirect="false"/>
       </action>
     </action-mappings>
      

  14.   

    if(id!=null&&id.equals("find")){
             c=feed.queryback();
             request.setAttribute("beanlist",c);
            }
    你把c里的东西取出来,在action里打印一下,看看有没有呢,也许可能是个空值。
    如果有值说明问题是在jsp页面,不在后面的DB。