新手弱弱的问:关于的问题

qinxiaofei 2007-07-13 02:27:51
jsp:页面

<%@ taglib uri="/struts-html" prefix="html" %>
<%@ taglib uri="/struts-bean" prefix="bean" %>
<%@ taglib uri="/struts-logic" prefix="logic" %>
<%@ taglib uri="/jstl/c" prefix="c" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<jsp:useBean id="depBean" scope="session" class="com.employee.DepartmentBean" />
<c:set var="departments" value="${depBean.getDepartment}" scope="page" />
<html:html locale="true">

JAVA类:
package com.employee;

import java.sql.*;
import java.util.*;

public class DepartmentBean {

private Connection conn;

public DepartmentBean()
{
conn = DataBaseConnection.getConnection();
}

public void addDepartment(Department dep) throws Exception
{
Statement stmt = conn.createStatement();

stmt.executeUpdate("insert into tb_department values('"+dep.getId()+"','"+
dep.getName()+"','"+dep.getDesc()+"','"+dep.getLeader()+"')");
}

public Collection getLeader() throws Exception
{
Statement stmt = conn.createStatement();
ResultSet rst = stmt.executeQuery("select * from tb_employee where emp_id not in( " +
"select dep_leader from tb_department)");
Collection<Employee> col = new ArrayList<Employee>();
while( rst.next() )
{
Employee temp = new Employee();
temp.setId(rst.getString("emp_id"));
temp.setName(rst.getString("emp_name"));
col.add(temp);
}
return col;
}

public Collection getDepartment() throws Exception
{
Statement stmt = conn.createStatement();
ResultSet rst = stmt.executeQuery("select * from tb_department");
Collection<Department> col = new ArrayList<Department>();

while( rst.next())
{
Department temp = new Department();
temp.setId(rst.getString("dep_id"));
temp.setName(rst.getString("dep_name"));
temp.setDesc(rst.getString("dep_desc"));
temp.setLeader(rst.getString("dep_leader"));

col.add(temp);
}

return col;
}
}

错误提示:
org.apache.jasper.JasperException: Unable to load class for JSP
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
...全文
208 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
zongxing 2007-08-01
  • 打赏
  • 举报
回复
作用范围不对。改成session
<c:set var="departments" value="${depBean.getDepartment}" scope="session" />
qinxiaofei 2007-07-13
  • 打赏
  • 举报
回复
没人回答

81,092

社区成员

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

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