请教标签访问set集合的问题.(在线等)!

lovepanzhe 2010-12-19 02:44:00
JSP代码如下,studentInfo中的属性都可以访问到,但是set集合访问不到,集合我已经加了相应的泛型,还是于事无补.
我用的是hibernate+struts2,请高手解答,抛出的异常如下:
org.apache.jasper.el.JspPropertyNotFoundException: /index.jsp(71,8) '${s.tblscores}' Property 'tblscores' not found on type com.sg.hibernate.util.TblStudent



<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.sg.hibernate.util.TblScore"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'index.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

</head>

<body>
<center>
<h1>
添加学生
</h1>
<form action="addStudent.action" method="post">
学生姓名:
<input type="text" name="stuName">
<input type="submit" value="添加">
</form>
<c:if test="${null!=studentInfo}">
<table>
<tr>
<td>
学生ID
</td>
<td>
学生姓名
</td>
<td>
数学
</td>
<td>
英语
</td>
<td>
语文
</td>
<td>
政治
</td>
</tr>
<c:forEach items="${requestScope.studentInfo}" var="s">
<tr>
<td>
${s.stid}
</td>
<td>
${s.sname}
</td>
<td>
<c:forEach items="${s.tblscores}" var="sets">
${sets }
</c:forEach>
</td>
</tr>
</c:forEach>
<tr></tr>
</table>
</c:if>
</center>
</body>
</html>
...全文
446 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
feichexia 2011-06-22
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 feichexia 的回复:]

引用 6 楼 zhuchao_ko 的回复:

引用 3 楼 lovepanzhe 的回复:
感谢一楼:遇到这个问题了,我想先把他弄好了,再去学strtus标签.
感谢二楼:我的集合是HashSet你给的例子是map啊....


............无语.

我也很无语~
[/Quote]
其根本是转换成iterator(迭代器),set能否化成iterator?
feichexia 2011-06-22
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 zhuchao_ko 的回复:]

引用 3 楼 lovepanzhe 的回复:
感谢一楼:遇到这个问题了,我想先把他弄好了,再去学strtus标签.
感谢二楼:我的集合是HashSet你给的例子是map啊....


............无语.
[/Quote]
我也很无语~
lovepanzhe 2010-12-19
  • 打赏
  • 举报
回复
这个真的没问题啊.main方法里面测试都可以的,只是jsp里面不知道用jstl怎么写的
sxdsly 2010-12-19
  • 打赏
  • 举报
回复
org.apache.jasper.el.JspPropertyNotFoundException: /index.jsp(71,8) '${s.tblscores}' Property 'tblscores' not found on type com.sg.hibernate.util.TblStudent

你写的EL表达式${s.tblscores},找不到tblscores属性,可能你的下面这个包com.sg.hibernate.util.TblStudent导入有问题。。。。

lovepanzhe 2010-12-19
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 zhuchao_ko 的回复:]
引用 3 楼 lovepanzhe 的回复:
感谢一楼:遇到这个问题了,我想先把他弄好了,再去学strtus标签.
感谢二楼:我的集合是HashSet你给的例子是map啊....


............无语.
[/Quote]

怎么个无语法?
宁波朱超 2010-12-19
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 lovepanzhe 的回复:]
感谢一楼:遇到这个问题了,我想先把他弄好了,再去学strtus标签.
感谢二楼:我的集合是HashSet你给的例子是map啊....
[/Quote]

............无语.
lovepanzhe 2010-12-19
  • 打赏
  • 举报
回复

没人来看啊
lovepanzhe 2010-12-19
  • 打赏
  • 举报
回复
拜托高手求解.顶啊.
lovepanzhe 2010-12-19
  • 打赏
  • 举报
回复
感谢一楼:遇到这个问题了,我想先把他弄好了,再去学strtus标签.
感谢二楼:我的集合是HashSet你给的例子是map啊....
Jlins 2010-12-19
  • 打赏
  • 举报
回复
给你个例子
模仿着做

var demo =map.values().iterator()
<c:forEach items="${demo}" var="food">
happyfmy 2010-12-19
  • 打赏
  • 举报
回复
你都用struts2了 就用它的标签<s:iterator>

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧