这个是我的代码:jsp:<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html>
<head>
<html:base />
<title>departmentSearch</title>
</head>
<body>
<html:form action="/department">
<table>
<tr>
<td>
部门名称
</td>
<td>
<html:text property="departmentName" />
<html:errors property="departmentName" />
</td>
<tr>
<td>
金额上限
</td>
<td>
<html:text property="max_Money" />
<html:errors property="max_Money" />
</td>
</tr>
<tr>
<td>
部门机构代码
</td>
<td>
<html:text property="agency_code" />
</td>
</tr>
<tr>
<td>
部门类别
</td>
<td>
<html:text property="dep_type" />
</td>
</tr>
<tr>
<td>
新规登陆日付
</td>
<td>
<html:text property="loginDate" />
<html:errors property="loginDate"/>
</td>
</tr>
<tr>
<td>
检索登陆日付
</td>
<td>
<html:text property="dateStart" />
<html:errors property="dateStart" />
</td>
<td>
~
</td>
<td>
<html:text property="dateEnd" />
<html:errors property="dateEnd" />
</td>
</tr>
<tr>
<td colspan=5></td>
<td>
<input type="button" onclick="search()" value="检索">
<input type="button" onclick="add()" value="新规">
<input type="reset" value="退出">
</td>
</tr>
</table>
<table border="1">
<tr>
<th>部门机构代码</th>
<th>部门略称</th>
<th>部门类别</th>
<th>金额上限</th>
<th>登陆日付</th>
</tr>
<logic:notEmpty name="department">
<logic:iterate id="element" name="department">
<tr>
<td>
<bean:write name="element" property="agency_code" />
</td>
<td>
<bean:write name="element" property="departmentName" />
</td>
<td>
<bean:write name="element" property="dep_type" />
</td>
<td>
<bean:write name="element" property="max_Money" />
</td>
<td>
<bean:write name="element" property="loginDate" />
</td>
</tr>
</logic:iterate>
</logic:notEmpty>
</table>
</html:form>
</body>
<script type="text/javascript">
function add(){
document.forms[0].action="/login/department.do?method=addDepartment";
document.forms[0].submit();
}
function search(){
document.forms[0].action="/login/department.do?method=searchDepartment";
document.forms[0].submit();
}
</script>
</html:html>Action:package zhanghz.action;import java.util.Vector;import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;import zhanghz.DAO.DepartmentDAO;
import zhanghz.DTO.DepartmentDTO;
import zhanghz.form.DepartmentForm;public class DepartmentAction extends DispatchAction {
public ActionForward addDepartment(ActionMapping mapping,ActionForm form,
HttpServletRequest request,HttpServletResponse response){
DepartmentForm departmentSearchForm = (DepartmentForm)form;
String departmentName = departmentSearchForm.getDepartmentName();
String agency_code = departmentSearchForm.getAgency_code();
float max_Money = departmentSearchForm.getMax_Money();
String dep_type = departmentSearchForm.getDep_type();
String loginDate = departmentSearchForm.getLoginDate();
DepartmentDAO department = new DepartmentDAO();
department.addDepartment(departmentName, agency_code, max_Money, dep_type, loginDate);
return mapping.findForward("addDepartment"); }
public ActionForward searchDepartment(ActionMapping mapping,ActionForm form,
HttpServletRequest request,HttpServletResponse response){
DepartmentForm departmentSearchForm = (DepartmentForm)form;
Vector departmentVector = new Vector();
String departmentName = departmentSearchForm.getDepartmentName();
String agency_code = departmentSearchForm.getAgency_code();
float max_Money = departmentSearchForm.getMax_Money();
String dep_type = departmentSearchForm.getDep_type();
String loginDate = departmentSearchForm.getLoginDate();
DepartmentDAO department = new DepartmentDAO();
departmentVector = department.searchDepartment(departmentName, agency_code, max_Money, dep_type, loginDate);
request.getSession().setAttribute("department", departmentVector);
return mapping.findForward("searchDepartment");
}}DTO 和 DAO 里面全是get,set方法。最后运行的时候就暴这个错:javax.servlet.ServletException: Cannot create iterator for this collection各位帮忙解决一下,由于注释是日文的,在此就不贴出来了
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html>
<head>
<html:base />
<title>departmentSearch</title>
</head>
<body>
<html:form action="/department">
<table>
<tr>
<td>
部门名称
</td>
<td>
<html:text property="departmentName" />
<html:errors property="departmentName" />
</td>
<tr>
<td>
金额上限
</td>
<td>
<html:text property="max_Money" />
<html:errors property="max_Money" />
</td>
</tr>
<tr>
<td>
部门机构代码
</td>
<td>
<html:text property="agency_code" />
</td>
</tr>
<tr>
<td>
部门类别
</td>
<td>
<html:text property="dep_type" />
</td>
</tr>
<tr>
<td>
新规登陆日付
</td>
<td>
<html:text property="loginDate" />
<html:errors property="loginDate"/>
</td>
</tr>
<tr>
<td>
检索登陆日付
</td>
<td>
<html:text property="dateStart" />
<html:errors property="dateStart" />
</td>
<td>
~
</td>
<td>
<html:text property="dateEnd" />
<html:errors property="dateEnd" />
</td>
</tr>
<tr>
<td colspan=5></td>
<td>
<input type="button" onclick="search()" value="检索">
<input type="button" onclick="add()" value="新规">
<input type="reset" value="退出">
</td>
</tr>
</table>
<table border="1">
<tr>
<th>部门机构代码</th>
<th>部门略称</th>
<th>部门类别</th>
<th>金额上限</th>
<th>登陆日付</th>
</tr>
<logic:notEmpty name="department">
<logic:iterate id="element" name="department">
<tr>
<td>
<bean:write name="element" property="agency_code" />
</td>
<td>
<bean:write name="element" property="departmentName" />
</td>
<td>
<bean:write name="element" property="dep_type" />
</td>
<td>
<bean:write name="element" property="max_Money" />
</td>
<td>
<bean:write name="element" property="loginDate" />
</td>
</tr>
</logic:iterate>
</logic:notEmpty>
</table>
</html:form>
</body>
<script type="text/javascript">
function add(){
document.forms[0].action="/login/department.do?method=addDepartment";
document.forms[0].submit();
}
function search(){
document.forms[0].action="/login/department.do?method=searchDepartment";
document.forms[0].submit();
}
</script>
</html:html>Action:package zhanghz.action;import java.util.Vector;import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;import zhanghz.DAO.DepartmentDAO;
import zhanghz.DTO.DepartmentDTO;
import zhanghz.form.DepartmentForm;public class DepartmentAction extends DispatchAction {
public ActionForward addDepartment(ActionMapping mapping,ActionForm form,
HttpServletRequest request,HttpServletResponse response){
DepartmentForm departmentSearchForm = (DepartmentForm)form;
String departmentName = departmentSearchForm.getDepartmentName();
String agency_code = departmentSearchForm.getAgency_code();
float max_Money = departmentSearchForm.getMax_Money();
String dep_type = departmentSearchForm.getDep_type();
String loginDate = departmentSearchForm.getLoginDate();
DepartmentDAO department = new DepartmentDAO();
department.addDepartment(departmentName, agency_code, max_Money, dep_type, loginDate);
return mapping.findForward("addDepartment"); }
public ActionForward searchDepartment(ActionMapping mapping,ActionForm form,
HttpServletRequest request,HttpServletResponse response){
DepartmentForm departmentSearchForm = (DepartmentForm)form;
Vector departmentVector = new Vector();
String departmentName = departmentSearchForm.getDepartmentName();
String agency_code = departmentSearchForm.getAgency_code();
float max_Money = departmentSearchForm.getMax_Money();
String dep_type = departmentSearchForm.getDep_type();
String loginDate = departmentSearchForm.getLoginDate();
DepartmentDAO department = new DepartmentDAO();
departmentVector = department.searchDepartment(departmentName, agency_code, max_Money, dep_type, loginDate);
request.getSession().setAttribute("department", departmentVector);
return mapping.findForward("searchDepartment");
}}DTO 和 DAO 里面全是get,set方法。最后运行的时候就暴这个错:javax.servlet.ServletException: Cannot create iterator for this collection各位帮忙解决一下,由于注释是日文的,在此就不贴出来了
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Vector;import zhanghz.DTO.DepartmentDTO;
import zhanghz.baseDAO.ConnectionDAO;public class DepartmentDAO {
Connection conn = null;
public void addDepartment(String departmentName,String agency_code,
float max_Money,String dep_type,String loginDate){
conn = new ConnectionDAO().initConn();
PreparedStatement preparedStatement = null;
String sql = "INSERT INTO DEPARTMENT(DEP_ID,SHORT_NAME,AGENCY_CODE,MAX_MONEY," +
"DEP_TYPE,LOGIN_TIME) VALUES (DEP_ID.NEXTVAL,?,?,?,?,?)";
try {
preparedStatement = conn.prepareStatement(sql);
preparedStatement.setString(1, departmentName);
preparedStatement.setString(2, agency_code);
preparedStatement.setFloat(3, max_Money);
preparedStatement.setString(4, dep_type);
preparedStatement.setString(5, loginDate);
preparedStatement.executeUpdate();
if(conn != null & !conn.isClosed()){
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
} public Vector searchDepartment(String departmentName,String agency_code,
float max_Money,String dep_type,String loginDate){
conn = new ConnectionDAO().initConn();
ResultSet depResultSet = null;
Vector<DepartmentDTO> depVector = new Vector<DepartmentDTO>();
DepartmentDTO departmentDTO = new DepartmentDTO();
Statement statement = null;
String originSql = "SELECT SHORT_NAME,AGENCY_CODE,MAX_MONEY,DEP_TYPE,LOGIN_TIME " +
"FROM DEPARTMENT WHERE "
+ returnDepartmentName(departmentName)
+ returnAgency_code(agency_code)
+ returnMax_Money(max_Money)
+ returnDep_type(dep_type) + returnLoginDate(loginDate);
String sql = originSql.substring(0, originSql.length()-4);
try {
statement = conn.createStatement();
depResultSet = statement.executeQuery(sql);
while(depResultSet.next()){
departmentDTO.setAgency_code(depResultSet.getString("AGENCY_CODE"));
departmentDTO.setDep_type(depResultSet.getString("DEP_TYPE"));
departmentDTO.setDepartmentName(depResultSet.getString("SHORT_NAME"));
departmentDTO.setLoginDate(depResultSet.getString("LOGIN_TIME"));
departmentDTO.setMax_Money(depResultSet.getFloat("MAX_MONEY"));
depVector.addElement(departmentDTO);
}
if(conn != null & !conn.isClosed()){
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
return depVector;
}
public String returnDepartmentName(String departmentName){
if(departmentName == null){
return "";
}else{
return " SHORT_NAME="+"'"+departmentName+"'"+" AND";
}
}
public String returnAgency_code(String agency_code){
if(agency_code == null){
return "";
}else{
return " AGENCY_CODE="+"'"+agency_code+"'"+" AND";
}
}
public String returnMax_Money(float max_Money){
if(max_Money == 0){
return "";
}else{
return " MAX_MONEY="+String.valueOf(max_Money)+" AND";
}
}
public String returnDep_type(String dep_type){
if(dep_type == null){
return "";
}else{
return " DEP_TYPE="+"'"+dep_type+"'"+" AND";
}
}
public String returnLoginDate(String loginDate){
if(loginDate == null){
return "";
}else{
return " LOGIN_TIME="+"'"+loginDate+"'"+" AND";
}
}
}