首先,在我的oracle数据库中有两表 users、dept,这两个表的部分javabean是这样写的
user表的部分javabean代码 private Long id;
private Dept dept;
private String username;
private String password;
private Long gender;
private Long role;
private String cardid;
private String actualName;
private String addr;
private String email;
private String comaddr;
private String position;
private String decraption;
private String spare2;
private String spare3;
private Set examUsers = new HashSet(0);dept表部分的javabean代码 private Long id;
private Dept dept;
private String dname;
private Long hasParent;
private Set userses = new HashSet(0);
private Set depts = new HashSet(0);在jsp页面中,我想通过jstl标签来<c:forEach>来迭代显示数据。其中,dept表的内容,我是通过拿到user表的中的dept对象,进而拿到dept表的各个字段的...比如:<td width="23%" style="text-align:left;">
<select name="dname">
<c:forEach items="${requestScope.usersEdit.dept}" var="list">
<option>${list.dname}</option>
</c:forEach>
</select>
</td>但它老是报错
org.apache.jasper.JasperException: An exception occurred processing JSP page /admin/userEdit.jsp at line 126
我查过126行,就是<c:forEach items="${requestScope.usersEdit.dept}" var="list">所以,我想问的是,<c:forEach>是不是不可以用在<option>标签当中,要是我直接写成这样
${requestScopt.usersEdit.dept.dname}就可以显示出一条数据,但并不是我想要的迭代显示!!!!如果可以用<c:forEach>标签的话,怎么才能让它用在<select name="gender"><option value="1"></option></select>当中!!!!!!!
user表的部分javabean代码 private Long id;
private Dept dept;
private String username;
private String password;
private Long gender;
private Long role;
private String cardid;
private String actualName;
private String addr;
private String email;
private String comaddr;
private String position;
private String decraption;
private String spare2;
private String spare3;
private Set examUsers = new HashSet(0);dept表部分的javabean代码 private Long id;
private Dept dept;
private String dname;
private Long hasParent;
private Set userses = new HashSet(0);
private Set depts = new HashSet(0);在jsp页面中,我想通过jstl标签来<c:forEach>来迭代显示数据。其中,dept表的内容,我是通过拿到user表的中的dept对象,进而拿到dept表的各个字段的...比如:<td width="23%" style="text-align:left;">
<select name="dname">
<c:forEach items="${requestScope.usersEdit.dept}" var="list">
<option>${list.dname}</option>
</c:forEach>
</select>
</td>但它老是报错
org.apache.jasper.JasperException: An exception occurred processing JSP page /admin/userEdit.jsp at line 126
我查过126行,就是<c:forEach items="${requestScope.usersEdit.dept}" var="list">所以,我想问的是,<c:forEach>是不是不可以用在<option>标签当中,要是我直接写成这样
${requestScopt.usersEdit.dept.dname}就可以显示出一条数据,但并不是我想要的迭代显示!!!!如果可以用<c:forEach>标签的话,怎么才能让它用在<select name="gender"><option value="1"></option></select>当中!!!!!!!
说明requestScopt.usersEdit.dept这个不是一个集合对象,你怎么迭代啊?
<select name="dname">
<c:forEach items="user" var="list">
<option>${user.dept.dname}</option>
</c:forEach>
</select>
</td>
<c:forEach items="集合" var="变量名">
<option>${变量名.属性} </option>
</c:forEach>
</select>
private Dept dept;//这不是一个集合把存入request作用域那附近的代码帖出来看看。
<c:forEach items="集合" var="变量名">
<option>${变量名.属性} </option>
</c:forEach>
</select>
从哪里过来的 把list的代码贴出来
有两种办法 第一个是在后台操作 第二个是 list.dname[name]
private Dept dept;
private String dname;
==>>dept bean这样定义有什么意义?c:foreach语法就那样,你先处理好自己的逻辑问题再解决显示的问题吧!
这里面只能放集合