小弟刚学JSP,在做一个人事管理软件的时候出现了问题.请大家帮忙看看

weiweihu1208 2007-07-30 10:37:18
JSP,在做一个人事管理软件的时候出现了问题:
在进行查询的时候,
1. 按照”出生日期范围”查询,即从自某年某月某日到某年某月某日进行查询!
2. 按照” 入司日期”查询,即从自某年某月某日到某年某月某日进行查询!
出现了错误.如下:
HTTP Status 500 -
________________________________________
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 31 in the jsp file: /employee/SearchEmployeeStep2.jsp
bir_from_id cannot be resolved
28: }
29:
30: Vector listemployee = Employee.Search(employeeid,username,sex,branch,nativeplace,marriage,politics,folk,education,administrationlevel,
31: duty,position,incumbency,incumbencytype,bir_from_id,accumulate_from_id);
32: %>
33: <html>
34: <head>


An error occurred at line: 31 in the jsp file: /employee/SearchEmployeeStep2.jsp
accumulate_from_id cannot be resolved
28: }
29:
30: Vector listemployee = Employee.Search(employeeid,username,sex,branch,nativeplace,marriage,politics,folk,education,administrationlevel,
31: duty,position,incumbency,incumbencytype,bir_from_id,accumulate_from_id);
32: %>
33: <html>
34: <head>


Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:435)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:298)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:299)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.23 logs.
________________________________________
Apache Tomcat/5.5.23

...全文
469 31 打赏 收藏 转发到动态 举报
写回复
用AI写文章
31 条回复
切换为时间正序
请发表友善的回复…
发表回复
weiweihu1208 2007-07-31
  • 打赏
  • 举报
回复
感谢bao110908。代码已经全部通过。谢谢
easyroom 2007-07-30
  • 打赏
  • 举报
回复
你说这些孩子怎么都不喜欢用ide呢。用个jb,eclipse啥的哪用费这个劲啊
waysue 2007-07-30
  • 打赏
  • 举报
回复
顶。楼上说的没错
  • 打赏
  • 举报
回复
你的 Search() 方法中定义了 14 个 String 类型的参数,而你使用时的参数有 16 个。所以就还是不对啦~~
weiweihu1208 2007-07-30
  • 打赏
  • 举报
回复
我把这两个变量换了.还是有问题:
HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 30 in the jsp file: /employee/SearchEmployeeStep2.jsp
The method Search(String, String, String, String, String, String, String, String, String, String, String, String, String, String) in the type Employee is not applicable for the arguments (String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String)
27: incumbencytype = new String(request.getParameter("incumbencytype").getBytes("ISO8859_1"),"GBK");
28: }
29:
30: Vector listemployee = Employee.Search(employeeid,username,sex,branch,nativeplace,marriage,politics,folk,education,administrationlevel,
31: duty,position,incumbency,incumbencytype,birthday,accumulateid);
32: %>
33: <html>


Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:435)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:298)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:299)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.23 logs.


--------------------------------------------------------------------------------

Apache Tomcat/5.5.23
  • 打赏
  • 举报
回复
你使用的变量是

String birthday = new String(request.getParameter("bir_from_id").getBytes("ISO8859_1"),"GBK");
String accumulateid = new String(request.getParameter("accumulate_from_id").getBytes("ISO8859_1"),"GBK");

而在

Vector listemployee = Employee.Search(employeeid,username,sex,branch,nativeplace,marriage,politics,folk,education,administrationlevel,
duty,position,incumbency,incumbencytype,bir_from_id,accumulate_from_id);

你使用的是 bir_from_id 和 accumulate_from_id,怎么会对呢?把这两个变量改成声明的那两个试试看。
weiweihu1208 2007-07-30
  • 打赏
  • 举报
回复
那应该怎么改?
<%@ page contentType="text/html;charset=gb2312" %>
<%@ include file="../incoming/Common.jsp"%>
<%@ include file="../Check.jsp"%>
<%
String employeeid = new String(request.getParameter("employeeid").getBytes("ISO8859_1"),"GBK");
String username = new String(request.getParameter("username").getBytes("ISO8859_1"),"GBK");
String sex = new String(request.getParameter("sex").getBytes("ISO8859_1"),"GBK");
String branch = new String(request.getParameter("branch").getBytes("ISO8859_1"),"GBK");
String nativeplace = new String(request.getParameter("nativeplace").getBytes("ISO8859_1"),"GBK");
String marriage = new String(request.getParameter("marriage").getBytes("ISO8859_1"),"GBK");
String politics = new String(request.getParameter("politics").getBytes("ISO8859_1"),"GBK");
String folk = new String(request.getParameter("folk").getBytes("ISO8859_1"),"GBK");
String education = new String(request.getParameter("education").getBytes("ISO8859_1"),"GBK");
String administrationlevel = new String(request.getParameter("administrationlevel").getBytes("ISO8859_1"),"GBK");
String duty = new String(request.getParameter("duty").getBytes("ISO8859_1"),"GBK");
String position = new String(request.getParameter("position").getBytes("ISO8859_1"),"GBK");
String birthday = new String(request.getParameter("bir_from_id").getBytes("ISO8859_1"),"GBK");
String accumulateid = new String(request.getParameter("accumulate_from_id").getBytes("ISO8859_1"),"GBK");

String incumbency = "";//new String(request.getParameter("incumbency").getBytes("ISO8859_1"),"GBK");
if(request.getParameter("incumbency")!=null){
incumbency = new String(request.getParameter("incumbency").getBytes("ISO8859_1"),"GBK");
}

String incumbencytype =""; //new String(request.getParameter("incumbencytype").getBytes("ISO8859_1"),"GBK");
if(request.getParameter("incumbencytype")!=null){
incumbencytype = new String(request.getParameter("incumbencytype").getBytes("ISO8859_1"),"GBK");
}

Vector listemployee = Employee.Search(employeeid,username,sex,branch,nativeplace,marriage,politics,folk,education,administrationlevel,
duty,position,incumbency,incumbencytype,bir_from_id,accumulate_from_id);
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<title><%=title%></title>
<link rel="stylesheet" href="../css/style.css" type="text/css" media="screen">
</head>
<body>
<%@ include file="../incoming/Header.jsp"%>
<table width="780" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td width="120" valign="top" background="../images/in_left_bg.gif"><%@ include file="EmployeeLeft.jsp"%></td>
<td width="660" align="center" valign="top">
<p align="center" class="title1">查询结果</p>
<table width="640" border="1" cellpadding="3" cellspacing="0" bordercolor="#CCCCCC">
<tr bgcolor="#E7E7E7">
<td width="67"><div align="center">员工编号</div></td>
<td width="39" bgcolor="#E7E7E7"><div align="center">姓名</div></td>
<td width="48"><div align="center">性别</div></td>
<td width="66"><div align="center">所属部门</div></td>
<td width="42"><div align="center">籍贯</div></td>
<td width="69"><div align="center">婚姻状况</div></td>
<td width="63"><div align="center">政治面貌</div></td>
<td width="48"><div align="center">学历</div></td>
<td width="55"><div align="center">职务</div></td>
<td width="61"><div align="center">在职情况</div></td>
</tr>
<%
for(int i=0;i<listemployee.size();i++)
{
Employee employee = (Employee)listemployee.elementAt(i);
%>
<tr>
<td><div align="center"><a href="ViewEmployeeStep1.jsp?employeeid=<%=employee.getEmployeeID()%>"><%=DataConvert.ViewStr(employee.getEmployeeID())%></a></div></td>
<td><div align="center"><%=DataConvert.ViewStr(employee.getUserName())%></div></td>
<td><div align="center"><%=DataConvert.ViewStr(employee.getSex())%></div></td>
<td><div align="center"><%=DataConvert.ViewStr(employee.getBranch())%></div></td>
<td><div align="center"><%=DataConvert.ViewStr(employee.getNativePlace())%></div></td>
<td><div align="center"><%=employee.getMarriage()%></div></td>
<td><div align="center"><%=DataConvert.ViewStr(employee.getPolitics())%></div></td>
<td><div align="center"><%=DataConvert.ViewStr(employee.getEducation())%></div></td>
<td><div align="center"><%=DataConvert.ViewStr(employee.getDuty())%></div></td>
<td><div align="center"><%=DataConvert.ViewStr(employee.getIncumbency())%></div></td>
</tr>
<%
}
%>
</table>
</td>
</tr>
</table>
<%@ include file="../incoming/Footer.jsp"%>
</body>
</html>
  • 打赏
  • 举报
回复
bir_from_id, accumulate_from_id 这两个变量没有声明。
weiweihu1208 2007-07-30
  • 打赏
  • 举报
回复
Birthday是出生年月,Accumulateid 是入司时间
  • 打赏
  • 举报
回复
数据库中只是一个 birthday 就可以了。

比如:要查询 2007-05-01 ~ 2007-06-01 的日期,就会把 birthday 中所有这个时间段内的值都匹配的。

你的 _Birthday 和 _Accumulateid 放的是什么东西?
weiweihu1208 2007-07-30
  • 打赏
  • 举报
回复
这位兄台你有QQ或MSN吗?
weiweihu1208 2007-07-30
  • 打赏
  • 举报
回复
那birthday_a, birthday_b 这两个值在数据库中不用再重新定义吗
weiweihu1208 2007-07-30
  • 打赏
  • 举报
回复
if (!_IncumbencyType.equals(""))strSQL = strSQL + " Birthday='" + _Birthday + "'AND";
if (!_IncumbencyType.equals(""))strSQL = strSQL + " Accumulateid='" + _Accumulateid + "' AND";改为什么呢?
  • 打赏
  • 举报
回复
如果是范围的话就需要两个变量,比如 Birthday,可以改成

... AND Brithday BETWEEN birthday_a AND birthday_b AND ...

birthday_a, birthday_b 这两个值可以从表单中获得。
weiweihu1208 2007-07-30
  • 打赏
  • 举报
回复
实现日期范围查询的还有什么办法?
weiweihu1208 2007-07-30
  • 打赏
  • 举报
回复
对.我没有写.应该在哪部分写?
  • 打赏
  • 举报
回复
BETWEEN .. AND.. 应该可以实现日期范围查询的,不过没在 SQL 中看到!你还没写?
weiweihu1208 2007-07-30
  • 打赏
  • 举报
回复
/*
* search Employee
*/
public static Vector Search(String _EmployeeID, String _UserName, String _Sex,
String _Branch, String _NativePlace, String _Marriage,
String _Politics, String _Folk, String _Education,
String _AdministrationLevel, String _Duty, String _Position,
String _Incumbency, String _IncumbencyType,String _birthday,String _accumulateid) {
DBConnect dbc = null;
Vector EmployeeVector = new Vector();

String strSQL = "SELECT * FROM employee WHERE";

if ((_EmployeeID.equals("")) & (_UserName.equals("")) & (_Sex.equals(""))
& (_Branch.equals("")) & (_NativePlace.equals("")) & (_Marriage.equals("")) & (_Politics.equals(""))
& (_Folk.equals("")) & (_Education.equals("")) & (_AdministrationLevel.equals("")) & (_Duty.equals(""))
& (_Position.equals("")) & (_Incumbency.equals("")) & (_IncumbencyType.equals(""))) {
strSQL = "SELECT * FROM employee ";
} else {
if (!_EmployeeID.equals(""))
strSQL = strSQL + " EmployeeID LIKE '%" + _EmployeeID + "%' AND";
if (!_UserName.equals(""))
strSQL = strSQL + " UserName='" + _UserName + "' AND";
if (!_Sex.equals(""))
strSQL = strSQL + " Sex='" + _Sex + "' AND";
if (!_Branch.equals(""))
strSQL = strSQL + " Branch='" + _Branch + "' AND";
if (!_NativePlace.equals(""))
strSQL = strSQL + " NativePlace LIKE '%" + _NativePlace + "%' AND";
if (!_Marriage.equals(""))
strSQL = strSQL + " Marriage='" + _Marriage + "' AND";
if (!_Politics.equals(""))
strSQL = strSQL + " Politics='" + _Politics + "' AND";
if (!_Folk.equals(""))
strSQL = strSQL + " Folk LIKE '%" + _Folk + "%' AND";
if (!_Education.equals(""))
strSQL = strSQL + " Education='" + _Education + "' AND";
if (!_AdministrationLevel.equals(""))
strSQL = strSQL + " AdministrationLevel='" + _AdministrationLevel + "' AND";
if (!_Duty.equals(""))
strSQL = strSQL + " Duty='" + _Duty + "' AND";
if (!_Position.equals(""))
strSQL = strSQL + " Position='" + _Position + "' AND";
if (!_Incumbency.equals(""))
strSQL = strSQL + " Incumbency='" + _Incumbency + "' AND";
if (!_IncumbencyType.equals(""))
strSQL = strSQL + " Birthday='" + _Birthday + "' AND";
if (!_IncumbencyType.equals(""))
strSQL = strSQL + " Accumulateid='" + _Accumulateid + "' AND";

strSQL = strSQL + " 1=1 ";
}

strSQL = strSQL + "ORDER BY EmployeeID ASC";

System.out.println(strSQL);

try {
dbc = new DBConnect();
dbc.prepareStatement(strSQL);
ResultSet rs = dbc.executeQuery();
while (rs.next()) {
Employee employee = new Employee();
employee.setEmployeeID(rs.getString("EmployeeID"));
employee.setUserName(rs.getString("UserName"));
employee.setSex(rs.getString("Sex"));
employee.setBranch(rs.getString("Branch"));
employee.setBirthday(rs.getString("Birthday"));
employee.setNativePlace(rs.getString("NativePlace"));
employee.setMarriage(rs.getString("Marriage"));
employee.setIdentityID(rs.getString("IdentityID"));
employee.setPolitics(rs.getString("Politics"));
employee.setFolk(rs.getString("Folk"));
employee.setEducation(rs.getString("Education"));
employee.setDepartment(rs.getString("Department"));
employee.setGraduateDate(rs.getString("GraduateDate"));
employee.setUniversity(rs.getString("University"));
employee.setAccumulateID(rs.getString("AccumulateID"));
employee.setAdministrationLevel(rs
.getString("AdministrationLevel"));
employee.setDuty(rs.getString("Duty"));
employee.setPosition(rs.getString("Position"));
employee.setForeignLanguage(rs.getString("ForeignLanguage"));
employee.setFLLevel(rs.getString("FLLevel"));
employee.setComputerLevel(rs.getString("ComputerLevel"));
employee.setPhone(rs.getString("Phone"));
employee.setMobilePhone(rs.getString("MobilePhone"));
employee.setAddress(rs.getString("Address"));
employee.setIncumbency(rs.getString("Incumbency"));
employee.setIncumbencyType(rs.getString("IncumbencyType"));
employee.setResume(rs.getString("Resume"));
EmployeeVector.add(employee);
}
} catch (Exception e) {
System.err.println(e);
} finally {
try {
dbc.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return EmployeeVector;

}

/*
* Update Employee Duty
*/
public static String UpdateDuty(String _EmployeeID, String _Duty) {
DBConnect dbc = null;
try {
dbc = new DBConnect();
dbc
.prepareStatement("UPDATE Employee SET Duty=? WHERE EmployeeID=?");
dbc.setString(1, _Duty);
dbc.setString(2, _EmployeeID);
dbc.executeUpdate();
dbc.close();
return "1";
} catch (Exception e) {
e.printStackTrace();
return e.toString();
}
}
weiweihu1208 2007-07-30
  • 打赏
  • 举报
回复
你的意思是对我JAVABEAN进行更改
weiweihu1208 2007-07-30
  • 打赏
  • 举报
回复

/*
* search Employee
*/
public static Vector Search(String _EmployeeID, String _UserName, String _Sex,
String _Branch, String _NativePlace, String _Marriage,
String _Politics, String _Folk, String _Education,
String _AdministrationLevel, String _Duty, String _Position,
String _Incumbency, String _IncumbencyType) {
DBConnect dbc = null;
Vector EmployeeVector = new Vector();

String strSQL = "SELECT * FROM employee WHERE";

if ((_EmployeeID.equals("")) & (_UserName.equals("")) & (_Sex.equals(""))
& (_Branch.equals("")) & (_NativePlace.equals("")) & (_Marriage.equals("")) & (_Politics.equals(""))
& (_Folk.equals("")) & (_Education.equals("")) & (_AdministrationLevel.equals("")) & (_Duty.equals(""))
& (_Position.equals("")) & (_Incumbency.equals("")) & (_IncumbencyType.equals(""))) {
strSQL = "SELECT * FROM employee ";
} else {
if (!_EmployeeID.equals(""))
strSQL = strSQL + " EmployeeID LIKE '%" + _EmployeeID + "%' AND";
if (!_UserName.equals(""))
strSQL = strSQL + " UserName='" + _UserName + "' AND";
if (!_Sex.equals(""))
strSQL = strSQL + " Sex='" + _Sex + "' AND";
if (!_Branch.equals(""))
strSQL = strSQL + " Branch='" + _Branch + "' AND";
if (!_NativePlace.equals(""))
strSQL = strSQL + " NativePlace LIKE '%" + _NativePlace + "%' AND";
if (!_Marriage.equals(""))
strSQL = strSQL + " Marriage='" + _Marriage + "' AND";
if (!_Politics.equals(""))
strSQL = strSQL + " Politics='" + _Politics + "' AND";
if (!_Folk.equals(""))
strSQL = strSQL + " Folk LIKE '%" + _Folk + "%' AND";
if (!_Education.equals(""))
strSQL = strSQL + " Education='" + _Education + "' AND";
if (!_AdministrationLevel.equals(""))
strSQL = strSQL + " AdministrationLevel='" + _AdministrationLevel + "' AND";
if (!_Duty.equals(""))
strSQL = strSQL + " Duty='" + _Duty + "' AND";
if (!_Position.equals(""))
strSQL = strSQL + " Position='" + _Position + "' AND";
if (!_Incumbency.equals(""))
strSQL = strSQL + " Incumbency='" + _Incumbency + "' AND";
if (!_IncumbencyType.equals(""))
strSQL = strSQL + " IncumbencyType='" + _IncumbencyType + "' AND";

strSQL = strSQL + " 1=1 ";
}

strSQL = strSQL + "ORDER BY EmployeeID ASC";

System.out.println(strSQL);

try {
dbc = new DBConnect();
dbc.prepareStatement(strSQL);
ResultSet rs = dbc.executeQuery();
while (rs.next()) {
Employee employee = new Employee();
employee.setEmployeeID(rs.getString("EmployeeID"));
employee.setUserName(rs.getString("UserName"));
employee.setSex(rs.getString("Sex"));
employee.setBranch(rs.getString("Branch"));
employee.setBirthday(rs.getString("Birthday"));
employee.setNativePlace(rs.getString("NativePlace"));
employee.setMarriage(rs.getString("Marriage"));
employee.setIdentityID(rs.getString("IdentityID"));
employee.setPolitics(rs.getString("Politics"));
employee.setFolk(rs.getString("Folk"));
employee.setEducation(rs.getString("Education"));
employee.setDepartment(rs.getString("Department"));
employee.setGraduateDate(rs.getString("GraduateDate"));
employee.setUniversity(rs.getString("University"));
employee.setAccumulateID(rs.getString("AccumulateID"));
employee.setAdministrationLevel(rs
.getString("AdministrationLevel"));
employee.setDuty(rs.getString("Duty"));
employee.setPosition(rs.getString("Position"));
employee.setForeignLanguage(rs.getString("ForeignLanguage"));
employee.setFLLevel(rs.getString("FLLevel"));
employee.setComputerLevel(rs.getString("ComputerLevel"));
employee.setPhone(rs.getString("Phone"));
employee.setMobilePhone(rs.getString("MobilePhone"));
employee.setAddress(rs.getString("Address"));
employee.setIncumbency(rs.getString("Incumbency"));
employee.setIncumbencyType(rs.getString("IncumbencyType"));
employee.setResume(rs.getString("Resume"));
EmployeeVector.add(employee);
}
} catch (Exception e) {
System.err.println(e);
} finally {
try {
dbc.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return EmployeeVector;

}

/*
* Update Employee Duty
*/
public static String UpdateDuty(String _EmployeeID, String _Duty) {
DBConnect dbc = null;
try {
dbc = new DBConnect();
dbc
.prepareStatement("UPDATE Employee SET Duty=? WHERE EmployeeID=?");
dbc.setString(1, _Duty);
dbc.setString(2, _EmployeeID);
dbc.executeUpdate();
dbc.close();
return "1";
} catch (Exception e) {
e.printStackTrace();
return e.toString();
}
}

/*
* Update Employee
*/
public static String UpdateBranch(String _EmployeeID, String _Branch) {
DBConnect dbc = null;
try {
dbc = new DBConnect();
dbc
.prepareStatement("UPDATE Employee SET Branch=? WHERE EmployeeID=?");
dbc.setString(1, _Branch);
dbc.setString(2, _EmployeeID);
dbc.executeUpdate();
dbc.close();
return "1";
} catch (Exception e) {
e.printStackTrace();
return e.toString();
}
}


}
加载更多回复(11)

81,094

社区成员

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

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