SSH问题

qjldx 2011-10-20 07:44:16
写了一个程序
package com.qjldx.domain;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;

@Entity
public class Student implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue
private int id;
private int xj=0;
private int kc=0;
private String kh;
private String xm;
private int yw=60 ;
private int sx=60 ;
private int yy=60 ;
private int wl=60 ;
private int hx=60 ;
private int sw=60 ;
private int zz=60 ;
private int ls=60 ;
private int dl=60 ;
private float zf=0.0f;
private int bmc=0 ;
private int lmc=0 ;


public int getXj() {
return xj;
}
public void setXj(int xj) {
this.xj = xj;
}

public int getKc() {
return kc;
}
public void setKc(int kc) {
this.kc = kc;
}
public String getKh() {
return kh;
}
public void setKh(String kh) {
this.kh = kh;
}
public String getXm() {
return xm;
}
public void setXm(String xm) {
this.xm = xm;
}
public int getYw() {
return yw;
}
public void setYw(int yw) {
this.yw = yw;
}
public int getSx() {
return sx;
}
public void setSx(int sx) {
this.sx = sx;
}
public int getYy() {
return yy;
}
public void setYy(int yy) {
this.yy = yy;
}
public int getWl() {
return wl;
}
public void setWl(int wl) {
this.wl = wl;
}
public int getHx() {
return hx;
}
public void setHx(int hx) {
this.hx = hx;
}
public int getSw() {
return sw;
}
public void setSw(int sw) {
this.sw = sw;
}
public int getZz() {
return zz;
}
public void setZz(int zz) {
this.zz = zz;
}
public int getLs() {
return ls;
}
public void setLs(int ls) {
this.ls = ls;
}
public int getDl() {
return dl;
}
public void setDl(int dl) {
this.dl = dl;
}
public float getZf() {
return zf;
}
public void setZf(float zf) {
this.zf = zf;
}
public int getBmc() {
return bmc;
}
public void setBmc(int bmc) {
this.bmc = bmc;
}
public int getLmc() {
return lmc;
}
public void setLmc(int lmc) {
this.lmc = lmc;
}
public void setId(int id) {
this.id = id;
}
public int getId() {
return id;
}

}
studentInfo.java
package com.qjldx.domain;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

@Entity
public class StudentInfo implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue
private int id;
//性别
private int xb=1 ;
//姓名
private String name="aa";
//名族
private String folk="aa" ;
//中考总分
private int zf1=0 ;
//界别
private int jb=1 ;
//原学校
private String xx="aaaa" ;
//录取类型 正取 自费
private int lqlx =1;
//录取学校
private String lqxx="xxxx" ;
//籍贯
private String hometown="xxxxxx" ;
//身份证
private String idCard="01000000" ;
//家庭住址
private String jtzz="howdress";
//联系电话
private String telephone="025-5032188";

private String homeAddress="homeAddress";
//学生学号
private String studentId="0200000";
//学生年级届别
private int studytype=3;
private Date begintime=new Date();
private int polity=3;
private int bj=1;
@ManyToOne
@JoinColumn(name="sid")
private Student student;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getXb() {
return xb;
}
public void setXb(int xb) {
this.xb = xb;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getFolk() {
return folk;
}
public void setFolk(String folk) {
this.folk = folk;
}
public int getZf1() {
return zf1;
}
public void setZf1(int zf1) {
this.zf1 = zf1;
}
public int getJb() {
return jb;
}
public void setJb(int jb) {
this.jb = jb;
}
public String getXx() {
return xx;
}
public void setXx(String xx) {
this.xx = xx;
}
public int getLqlx() {
return lqlx;
}
public void setLqlx(int lqlx) {
this.lqlx = lqlx;
}
public String getLqxx() {
return lqxx;
}
public void setLqxx(String lqxx) {
this.lqxx = lqxx;
}
public String getHometown() {
return hometown;
}
public void setHometown(String hometown) {
this.hometown = hometown;
}
public String getIdCard() {
return idCard;
}
public void setIdCard(String idCard) {
this.idCard = idCard;
}
public String getJtzz() {
return jtzz;
}
public void setJtzz(String jtzz) {
this.jtzz = jtzz;
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}

public String getHomeAddress() {
return homeAddress;
}
public void setHomeAddress(String homeAddress) {
this.homeAddress = homeAddress;
}
public String getStudentId() {
return studentId;
}
public void setStudentId(String studentId) {
this.studentId = studentId;
}
public int getStudytype() {
return studytype;
}
public void setStudytype(int studytype) {
this.studytype = studytype;
}
public Date getBegintime() {
return begintime;
}
public void setBegintime(Date begintime) {
this.begintime = begintime;
}
public void setPolity(int polity) {
this.polity = polity;
}
public int getPolity() {
return polity;
}
public void setBj(int bj) {
this.bj = bj;
}
public int getBj() {
return bj;
}
public void setStudent(Student student) {
this.student = student;
}
public Student getStudent() {
return student;
}

}
studentServiceImpl.java
package com.qjldx.service.impl;

import java.io.File;
import java.util.Iterator;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Component;

import com.qjldx.dao.AdminDao;
import com.qjldx.dao.StudentDao;
import com.qjldx.dao.StudentInfoDao;
import com.qjldx.domain.Student;
import com.qjldx.domain.StudentInfo;
import com.qjldx.service.StudentService;
@Component("studentService")
@Scope("prototype")
public class StudentServiceImpl implements StudentService {

@Resource
private AdminDao adminDao;
@Resource
private StudentDao studentDao;
private Student student;
@Resource
private StudentInfoDao studentInfoDao;

public List<Student> findAllStudent() {
List<Student> students=(List<Student>) studentDao.findAll();
return students;
}

public List<StudentInfo> findAllStudentinfo() {
List<StudentInfo> studentInfos=(List<StudentInfo>) studentInfoDao.findAll();
return studentInfos;
}

public StudentInfo studentinfoadd(StudentInfo studentInfo){

Student s=new Student();
s.setXm(studentInfo.getName());
studentInfo.setStudent(s);
studentInfoDao.create(studentInfo);
studentDao.create(s);
return studentInfo;
}
在调用studentInfoadd()这个方法时出现错误:
Struts Problem Report
Struts has detected an unhandled exception:

Messages: java.lang.Integer cannot be cast to com.qjldx.domain.StudentInfo

File: com/qjldx/dao/impl/StudentInfoDaoImpl.java
Line number: 30


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

Stacktraces
java.lang.ClassCastException: java.lang.Integer cannot be cast to com.qjldx.domain.StudentInfo
com.qjldx.dao.impl.StudentInfoDaoImpl.create(StudentInfoDaoImpl.java:30)
com.qjldx.service.impl.StudentServiceImpl.studentinfoadd(StudentServiceImpl.java:46)
com.qjldx.action.StudentInfoAction.add(StudentInfoAction.java:45)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
in your WEB-INF/classes/struts.properties file.
但是在Test测试时正常,能按要求插入,请帮忙
...全文
126 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
wingson_shen 2011-10-20
  • 打赏
  • 举报
回复
StudentInfoDaoImpl 这个类没有贴出来???

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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