恩 jstl 看完了 刚才用了下 对于一个表的取数据没的问题 但是两个表的查询显示就有问题了 怎么向一个表那样取读pojo里面的 现在报错是 javax.servlet.ServletException: The "." operator was supplied with an index value of type "java.lang.String" to be applied to a List or array, but that value cannot be converted to an integer. 这个该怎么改了?
代码public List All_user() { // TODO 自动生成方法存根 List l = null ; String hql = "FROM Struts_user As s,Trys as t where s.id=t.userid" ; Query q = this.session.createQuery(hql); l = q.list(); return l; }这个是查询的功能代码 List alluser = DaoFactory.getPersonDAOInstance().All_user();
System.out.println("----------------------------------"+alluser.size());这个是用工厂模式做的 test。java测试文件 里面显示有3条记录request.setAttribute("trylist",alluser); 这个是action 转向到页面的 页面我现在就这样的 只是读 <c:forEach items="${requestScope.trylist}" var="thistry"> ${thistry.Struts_user.userid} </c:forEach> 读了一个${thistry.userid} 开始是这样的 错了我才改成${thistry.Struts_user.userid} 还是不行 pojo 是 Struts_user 和 trys通过关联后 查询的结果是3 (alluser.size();)这个是对了的 Hibernate: select struts_use0_.id as id21_0_, trys1_.tid as tid20_1_, struts_use0_.username as username21_0_, struts_use0_.userpasw as userpasw21_0_, struts_use0_.usersex as usersex21_0_, trys1_.userid as userid20_1_, trys1_.content as content20_1_ from struts.dbo.struts_user struts_use0_, struts.dbo.trys trys1_ where struts_use0_.id=trys1_.userid 这个是hql的语句
不是 javax.servlet.ServletException: The ". " operator was supplied with an index value of type "java.lang.String " to be applied to a List or array, but that value cannot be converted to an integer. 这个
早更正早受益.
至于优化,应该把精力放在business和DB层,JSTL的显示,按实际需要显示就行.
jstl 看完了 刚才用了下 对于一个表的取数据没的问题 但是两个表的查询显示就有问题了 怎么向一个表那样取读pojo里面的
现在报错是
javax.servlet.ServletException: The "." operator was supplied with an index value of type "java.lang.String" to be applied to a List or array, but that value cannot be converted to an integer.
这个该怎么改了?
代码public List All_user() {
// TODO 自动生成方法存根
List l = null ;
String hql = "FROM Struts_user As s,Trys as t where s.id=t.userid" ;
Query q = this.session.createQuery(hql);
l = q.list();
return l;
}这个是查询的功能代码 List alluser = DaoFactory.getPersonDAOInstance().All_user();
System.out.println("----------------------------------"+alluser.size());这个是用工厂模式做的
test。java测试文件 里面显示有3条记录request.setAttribute("trylist",alluser); 这个是action 转向到页面的 页面我现在就这样的 只是读
<c:forEach items="${requestScope.trylist}" var="thistry">
${thistry.Struts_user.userid}
</c:forEach>
读了一个${thistry.userid} 开始是这样的 错了我才改成${thistry.Struts_user.userid} 还是不行
pojo 是 Struts_user 和 trys通过关联后 查询的结果是3 (alluser.size();)这个是对了的
Hibernate: select struts_use0_.id as id21_0_, trys1_.tid as tid20_1_, struts_use0_.username as username21_0_, struts_use0_.userpasw as userpasw21_0_, struts_use0_.usersex as usersex21_0_, trys1_.userid as userid20_1_, trys1_.content as content20_1_ from struts.dbo.struts_user struts_use0_, struts.dbo.trys trys1_ where struts_use0_.id=trys1_.userid
这个是hql的语句
javax.servlet.ServletException: The ". " operator was supplied with an index value of type "java.lang.String " to be applied to a List or array, but that value cannot be converted to an integer.
这个