急、急、急、 请高手帮忙 最好详细一点 这个框架不怎么熟悉

断点 2011-05-25 02:31:13
dao层

public void updateStudent(StudentVO student) throws DAOException {
try {
if(null != student){
this.getSqlMapClient().update("updateStudent", student);
}
} catch (Exception e) {
throw new DAOException(e);
}
}

biz层

// 修改所有学员信息
public void updateStudent(StudentVO student) throws DAOException {
this.studentDao.updateStudent(student);
}


action层

// 跳转到修改页面
public ActionForward toUpdateStudent(ActionMapping mapping,
ActionForm actionForm, HttpServletRequest request,
HttpServletResponse response) throws DAOException{
//StudentForm stuForm = (StudentForm)actionForm;

String stuId = request.getParameter("stuId");
StudentVO stuVO = new StudentVO();
stuVO = studentService.getStudentAllById(stuId);
request.setAttribute("stuVO", stuVO);

return mapping.findForward("updateStudent");
}
/**
* 修改学员信息
* @param mapping
* @param actionForm
* @param request
* @param response
* @return
* @throws DAOException
*/
public ActionForward doUpdateStudent(ActionMapping mapping,
ActionForm actionForm, HttpServletRequest request,
HttpServletResponse response) throws DAOException{
StudentForm stuForm = (StudentForm)actionForm;

StudentVO stuVO = new StudentVO();
stuVO.setStuId(stuForm.getStuId());
stuVO.setStuName(stuForm.getStuName());
stuVO.setStuAddress(stuForm.getStuAddress());

this.studentService.updateStudent(stuVO);
return this.doStudentList(mapping, actionForm, request, response);
}



然后就是保这样的错 javax.servlet.ServletException: java.lang.ClassCastException: java.lang.String
不知道怎么修改 用的是Struts+Spring+iBatis框架
...全文
70 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
断点 2011-05-25
  • 打赏
  • 举报
回复
谢谢大家 错误解决了 谢谢你们的建议
_斑驳旳青春 2011-05-25
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 flyingfish1987 的回复:]
// 跳转到修改页面
public ActionForward toUpdateStudent(ActionMapping mapping,
ActionForm actionForm, HttpServletRequest request,
HttpServletResponse response) throws DAOException{
//StudentForm s……
[/Quote]
如果struts的form里面配置的就是string是不需要强转的。。他都说了全部string
flyingfish1987 2011-05-25
  • 打赏
  • 举报
回复
// 跳转到修改页面
public ActionForward toUpdateStudent(ActionMapping mapping,
ActionForm actionForm, HttpServletRequest request,
HttpServletResponse response) throws DAOException{
//StudentForm stuForm = (StudentForm)actionForm;

String stuId = request.getParameter("stuId"); StudentVO stuVO = new StudentVO();
stuVO = studentService.getStudentAllById(stuId);
request.setAttribute("stuVO", stuVO);

return mapping.findForward("updateStudent");
}
是不是标红的这段错了,你强制转换一下吧
wl_ldy 2011-05-25
  • 打赏
  • 举报
回复
首先需要单步debug调试一下,定位到java.lang.ClassCastException异常信息是在
哪行出现的...
_斑驳旳青春 2011-05-25
  • 打赏
  • 举报
回复
还有如果你有实体类的话也贴出来。。
肯定是你类型设置或者加入的时候出错的
_斑驳旳青春 2011-05-25
  • 打赏
  • 举报
回复
把报的错误全部贴出来看看
断点 2011-05-25
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 adore_art 的回复:]
java.lang.String
自己去配置文件里面去找,是不是string类型不配对数据库类型的。。
[/Quote]
全部是String类型的
_斑驳旳青春 2011-05-25
  • 打赏
  • 举报
回复
java.lang.String
自己去配置文件里面去找,是不是string类型不配对数据库类型的。。

67,515

社区成员

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

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