我不知道这有什么问题。当我使用"from Structure"
时,它正在工作。但是,如果我将其扩展为
"SELECT S.id, S.firstName, S.middleName, S.lastName, S.gender, S.birthdate, S.course, S.phone, S.address, S.classCode from StudentStructure S"
错误是:
javax.servlet.jsp.JspException: No getter method for property id of bean showStudent
at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:716)
at org.apache.struts.taglib.bean.WriteTag.doStartTag(WriteTag.java:290)
at org.apache.jsp.WEB_002dINF.crud.show_jsp._jspx_meth_bean_005fwrite_005f0(show_jsp.java:330)
at org.apache.jsp.WEB_002dINF.crud.show_jsp._jspService(show_jsp.java:165)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:387)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:687)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:469)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:403)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:972)
at org.apache.struts.action.RequestProcessor.processActionForward(RequestProcessor.java:408)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:269)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1109)
at com.getcare.utility.web.GetcareActionServlet.process(GetcareActionServlet.java:139)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:452)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:437)
at org.apache.coyote.ajp.AjpProtocol$AjpConnectionHandler.process(AjpProtocol.java:381)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
10:52:50,230 INFO [STDOUT] - Servlet.service() for servlet action threw exception
javax.servlet.jsp.JspException: No getter method for property id of bean showStudent
at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:716)
at org.apache.struts.taglib.bean.WriteTag.doStartTag(WriteTag.java:290)
at org.apache.jsp.WEB_002dINF.crud.show_jsp._jspx_meth_bean_005fwrite_005f0(show_jsp.java:330)
at org.apache.jsp.WEB_002dINF.crud.show_jsp._jspService(show_jsp.java:165)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:387)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:687)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:469)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:403)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:972)
at org.apache.struts.action.RequestProcessor.processActionForward(RequestProcessor.java:408)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:269)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1109)
at com.getcare.utility.web.GetcareActionServlet.process(GetcareActionServlet.java:139)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:452)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:437)
at org.apache.coyote.ajp.AjpProtocol$AjpConnectionHandler.process(AjpProtocol.java:381)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
这是结构:
import java.io.Serializable;
import java.util.ArrayList;
import com.getcare.remote.Structure;
/**
*
* @author clemjon
*
* @hibernate.class table="student"
*/
public class StudentStructure extends Structure implements Serializable{
private Integer id;
private Integer phone,classCode;
private String firstName, middleName, lastName, gender, birthdate, course,address;
private ArrayList students;
StudentContactInfoStructure contact = new StudentContactInfoStructure();
public ArrayList getStudents() {
return students;
}
public void setStudents(ArrayList arrayList) {
this.students = arrayList;
}
/**
* @hibernate.id generator-class="sequence"
* @hibernate.generator-param name="sequence" value="student_id_seq"
*/
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
/**
* @hibernate.property
*
*/
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
/**
* @hibernate.property
*
*/
public String getMiddleName() {
return middleName;
}
public void setMiddleName(String middleName) {
this.middleName = middleName;
}
/**
* @hibernate.property
*
*/
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
/**
* @hibernate.property
*
*/
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
/**
* @hibernate.property
*
*/
public String getBirthdate() {
return birthdate;
}
public void setBirthdate(String birthdate) {
this.birthdate = birthdate;
}
/**
* @hibernate.property
*
*/
public String getCourse() {
return course;
}
public void setCourse(String course) {
this.course = course;
}
/**
* @hibernate.property
*
*/
public Integer getPhone(){
return phone;
}
public void setPhone(Integer phone){
this.phone = phone;
this.contact.setPhone(phone);
}
/**
* @hibernate.property
*
*/
public String getAddress(){
return address;
}
public void setAddress(String address){
this.address = address;
this.contact.setAddress(address);
}
/**
* @hibernate.property
*
*/
public Integer getClassCode(){
return classCode;
}
public void setClassCode(Integer classCode) {
this.classCode = classCode;
}
}
这是 JSP:
<strike>
<%@ page contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%>
<%@ taglib uri="/WEB-INF/struts-form.tld" prefix="form" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<jsp:useBean id="studentForm" class="com.getcare.crud.web.StudentForm" scope="session"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<form:html >
<head>
<title>Show Student</title>
<script>
function validate()
{
var confirmMessage="All record of the student will be deleted. Click OK to continue.";
if(confirm(confirmMessage)==false)
{
return false;
}
}
</script>
</head>
<body>
<table border=1>
<thead>
<tr bgcolor="#3CB371">
<th>Student Number</th>
<th>First Name</th>
<th>Middle Name</th>
<th>Last Name</th>
<th>Gender</th>
<th>Birth Date</th>
<th>Course</th>
<th>Phone</th>
<th>Address</th>
<th>Subject</th>
<th colspan=2>Action</th>
<th colspan=2>Add</th>
</tr>
</thead>
<% int count = 0; %>
<logic:iterate id="showStudent" name="studentForm" property="students">
<tbody>
<tr bgcolor="#E0FFFF">
<td><bean:write name="showStudent" property="id"/></td>
<td><bean:write name="showStudent" property="firstName"/></td>
<td><bean:write name="showStudent" property="middleName"/></td>
<td><bean:write name="showStudent" property="lastName"/></td>
<td><bean:write name="showStudent" property="gender"/></td>
<td><bean:write name="showStudent" property="birthdate"/></td>
<td><bean:write name="showStudent" property="course"/></td>
<td><bean:write name="showStudent" property="phone"/></td>
<td><bean:write name="showStudent" property="address"/></td>
<td><bean:write name="showStudent" property="classCode"/></td>
<td><a href="/orprovider/crud/updateForm.do?id=<bean:write name="showStudent" property="id" format="##########"/>&firstName=<bean:write name="showStudent" property="firstName" format="##########"/>&middleName=<bean:write name="showStudent" property="middleName" format="##########"/>&lastName=<bean:write name="showStudent" property="lastName" format="##########"/>&gender=<bean:write name="showStudent" property="gender" format="##########"/>&birthdate=<bean:write name="showStudent" property="birthdate" format="##########"/>&course=<bean:write name="showStudent" property="course" format="##########"/>&classCode=<bean:write name="showStudent" property="classCode" format="##########"/>&phone=<bean:write name="showStudent" property="phone" format="##########"/>&address=<bean:write name="showStudent" property="address" format="##########"/>">Update</a></td>
<td><a href="/orprovider/crud/crudAction.do?method=delete&classCode=<bean:write name="showStudent" property="id" format="##########"/>" onclick="return validate()">Delete</a></td>
<td><a href="/orprovider/crud/forwardAdd.do?id=<bean:write name="showStudent" property="id" format="##########"/>&firstName=<bean:write name="showStudent" property="firstName" format="##########"/>&middleName=<bean:write name="showStudent" property="middleName" format="##########"/>&lastName=<bean:write name="showStudent" property="lastName" format="##########"/>&gender=<bean:write name="showStudent" property="gender" format="##########"/>&birthdate=<bean:write name="showStudent" property="birthdate" format="##########"/>&course=<bean:write name="showStudent" property="course" format="##########"/>&phone=<bean:write name="showStudent" property="phone" format="##########"/>">Class / Contact Info</a></td>
</tr>
</tbody>
<% count++; %>
</logic:iterate>
</table>
Records found: <%=count %> <br />
<form:link href="http://orgetcare/orprovider/crud/options.do">Return to Options</form:link>
</body>
</form:html>
</strike>
学生形式:
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import net.sf.hibernate.mapping.Collection;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import com.getcare.crud.remote.StudentContactInfoStructure;
import com.getcare.crud.remote.StudentStructure;
public class StudentForm extends ActionForm{
private StudentStructure student = new StudentStructure();
private StudentContactInfoStructure studentContact = new StudentContactInfoStructure();
private ArrayList students = new ArrayList();
private ArrayList studentContacts = new ArrayList();
private int studentid;
// private ArrayList s= new ArrayList();
// public ArrayList getS() {
// return (ArrayList) Arrays.asList(students,studentContacts);
// }
// public void setS(ArrayList s) {
// this.s = (ArrayList) Arrays.asList(students,studentContacts);
// }
public int getId() {
return student.getId();
}
public void setId(int id){
student.setId(id);
studentContact.setId(student.getId());
// studentContact.setStudentid(id);
}
public void setFirstName(String firstName) {
student.setFirstName(firstName);
}
public void setMiddleName(String middleName) {
student.setMiddleName(middleName);
}
public void setLastName(String lastName) {
student.setLastName(lastName);
}
public void setGender(String gender) {
student.setGender(gender);
}
public void setBirthdate(String birthdate) {
student.setBirthdate(birthdate);
}
public void setCourse(String course) {
student.setCourse(course);
}
public void setPhone(Integer phone){
student.setPhone(phone);
studentContact.setPhone(phone);
}
public void setAddress(String address){
student.setAddress(address);
studentContact.setAddress(address);
}
public void setClassCode(Integer classCode) {
student.setClassCode(classCode);
}
public String getFirstName() {
return student.getFirstName();
}
public String getMiddleName() {
return student.getMiddleName();
}
public String getLastName() {
return student.getLastName();
}
public String getGender() {
return student.getGender();
}
public String getBirthdate() {
return student.getBirthdate();
}
public String getCourse() {
return student.getCourse();
}
public Integer getPhone(){
return student.getPhone();
}
public String getAddress(){
return student.getAddress();
}
public Integer getClassCode(){
return student.getClassCode();
}
public Integer getStudentid() {
return studentContact.getId();
}
public void setStudentid(int studentid) {
studentContact.setId(student.getId());
studentContact.setStudentid(studentid);
}
@Override
public void reset(ActionMapping mapping, HttpServletRequest request) {
super.reset(mapping, request);
// setId(0);
setFirstName(null);
setLastName(null);
setMiddleName(null);
setGender(null);
setBirthdate(null);
setCourse(null);
setPhone(null);
setAddress(null);
setClassCode(null);
}
public ArrayList getStudents() {
return student.getStudents();
}
public void setStudents(ArrayList students) {
this.student.setStudents(students);
}
public ArrayList getStudentContacts() {
return studentContact.getStudentContacts();
}
public void setStudentContacts(ArrayList studentContacts) {
this.studentContact.setStudentContacts(studentContacts);
}
public StudentContactInfoStructure getStudentContact() {
return studentContact;
}
public void setStudentContact(StudentContactInfoStructure studentContact) {
this.studentContact = studentContact;
}
public StudentStructure getStudent() {
return student;
}
public void setStudent(StudentStructure student) {
this.student = student;
}
}