页面代码
<tr bgcolor="#FFFFFF">
                  <td height="28" align="center">负责社团</td>
                  <td width="40" height="60">
                    <select id="corporationId" >
                      <option value="" selected="selected">请选择社团</option>
                        <c:forEach items="${corporations}" var="corporation">
                         <option value="${corporation.id}">${corporation.name}</option>
                        </c:forEach>
                    </select>
                  </td>
                </tr>报错内容:org.apache.jasper.JasperException: java.lang.NumberFormatException: For input string: "id"
id 是String型
当我这样写时 
<c:forEach items="${corporations}" var="corporation">
     <option value=""></option>
</c:forEach>
页面不报错

解决方案 »

  1.   

    报错的意思是字符串"id"转成数值型失败
    你确定corporation里的id属性是String型的???
      

  2.   

    corporation的定义贴出来看看吧
      

  3.   

    实体类的定义
    package com.whitefree.orm;import java.io.Serializable;
    import java.util.Date;public class Corporation implements Serializable{  /**
     * 
     */
    private static final long serialVersionUID = 1L;

            private String id;        //社团编号
    private String name;      //社团名称
    private String type;      //社团类型
    private String intro;     //社团宗旨
    private Date foundDate;   //社团创建时间
    private Users teacher;    //负责教师
    private String delFlag;   //删除标记

    public Corporation() {
    super();
    } public Corporation(String id, String name, String type, String intro,
    Date foundDate, Users teacher, String delFlag) {
    super();
    this.id = id;
    this.name = name;
    this.type = type;
    this.intro = intro;
    this.foundDate = foundDate;
    this.teacher = teacher;
    this.delFlag = delFlag;
    }servlet里的方法
    public void queryMyCorporation(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{

    HttpSession session=request.getSession();                 //获得session
    Users teacher=(Users) session.getAttribute("loginer");    //从登陆的servlet中获得登陆者信息
    CorporationDAOImpl corporationDAOImpl = new CorporationDAOImpl();  //实例化社团的DAO操作类
    //根据教师编号查询社团
    System.out.println(teacher.getId());
    List<Corporation> corporations=corporationDAOImpl.findCorporationByTeacherId(teacher.getId());
    session.setAttribute("corporations", corporations);
    request.getRequestDispatcher("/teacher/addLeader.jsp").forward(request, response);

    }
      

  4.   

    找到问题了,我的DAOImpl根据教师编号查询社团使用的是SQLQuery,
    结果查询的结果我直接使用query.list,导致类型转换异常。
    使用query就好了,谢谢大家了