出现javax.servlet.ServletException: javax.servlet.jsp.el.ELException: 异常! 15
User.java的源代码:packagecom.ncu.beans;publicclassUser{privateStringuserId;privateStringu...
User.java的源代码:
package com.ncu.beans;
public class User {
private String userId;
private String userName;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
}
UserBean.java源代码:
package com.ncu.beans;
import java.sql.*;
import java.util.*;
public class UserBean{
private DataBaseCon dbcon=new DataBaseCon();
private Connection con=null;
public UserBean(){
this.con=dbcon.getCon();
}
public Collection getUsers() throws Exception
{
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from user");
Collection ret=new ArrayList();
while(rs.next())
{
User temp=new User();
temp.setUserId(rs.getString("userId"));
temp.setUserName(rs.getString("userName"));
ret.add(temp);
}
return ret;
}
}
user.jsp源代码:
<%@ page language="java" pageEncoding="gb2312"% >
<%@page import="com.ncu.beans.UserBean"% >
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" % >
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" % >
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" % >
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" % >
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" % >
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" >
<html:html lang="true" >
<head >
<html:base / >
<title >user.jsp </title >
</head >
<body >
<jsp:useBean id="users" scope="session" class="com.ncu.beans.UserBean"/ >
<c:set var="users" value="${users.users}"/ >
<logic:iterate id="temp1" name="users" >
<bean:write name="temp1" property="userId"/ >
<bean:write name="temp1" property="userName"/ >
</logic:iterate >
</body >
</html:html >
编译时出现如下异常:
exception
javax.servlet.ServletException: javax.servlet.jsp.el.ELException: An error occurred while getting property "users" from an instance of class com.ncu.beans.UserBean
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:821)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.user_jsp._jspService(user_jsp.java:162)
请问如何解决!
兄弟,{users.users}就是表示通过对象users调用getUsers()的方法!书、例子我早就看过了!
我是因为上次重装了一下MyEclipse6.0,把以前做成功的这个工程导入后,就出现这样的错误! 展开
package com.ncu.beans;
public class User {
private String userId;
private String userName;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
}
UserBean.java源代码:
package com.ncu.beans;
import java.sql.*;
import java.util.*;
public class UserBean{
private DataBaseCon dbcon=new DataBaseCon();
private Connection con=null;
public UserBean(){
this.con=dbcon.getCon();
}
public Collection getUsers() throws Exception
{
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from user");
Collection ret=new ArrayList();
while(rs.next())
{
User temp=new User();
temp.setUserId(rs.getString("userId"));
temp.setUserName(rs.getString("userName"));
ret.add(temp);
}
return ret;
}
}
user.jsp源代码:
<%@ page language="java" pageEncoding="gb2312"% >
<%@page import="com.ncu.beans.UserBean"% >
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" % >
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" % >
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" % >
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" % >
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" % >
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" >
<html:html lang="true" >
<head >
<html:base / >
<title >user.jsp </title >
</head >
<body >
<jsp:useBean id="users" scope="session" class="com.ncu.beans.UserBean"/ >
<c:set var="users" value="${users.users}"/ >
<logic:iterate id="temp1" name="users" >
<bean:write name="temp1" property="userId"/ >
<bean:write name="temp1" property="userName"/ >
</logic:iterate >
</body >
</html:html >
编译时出现如下异常:
exception
javax.servlet.ServletException: javax.servlet.jsp.el.ELException: An error occurred while getting property "users" from an instance of class com.ncu.beans.UserBean
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:821)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.user_jsp._jspService(user_jsp.java:162)
请问如何解决!
兄弟,{users.users}就是表示通过对象users调用getUsers()的方法!书、例子我早就看过了!
我是因为上次重装了一下MyEclipse6.0,把以前做成功的这个工程导入后,就出现这样的错误! 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询