我正在将数值插入数据库,但我得到的是UIException,这是我的代码示例,
public void createTeacherInfo(HttpServletRequest request) {
try{
TeacherInfo teacherInfo= new TeacherInfo();
request.getParameter("flowName");
DateFormat df = new SimpleDateFormat("dd-mm-yyyy");
String tId= request.getParameter("teacherId");
teacherInfo.setTeahcerId(Integer.parseInt(tId));
//teacherInfo.setTeahcerId(Integer.parseInt(request.getParameter("teacherId")));
teacherInfo.setTeacherName(request.getParameter("teacherName"));
/*teacherInfo.setDob(df.parse(request.getParameter("dob")));
teacherInfo.setDoj(df.parse(request.getParameter("doj")));*/
teacherInfo.setTeacherEducation(request.getParameter("education"));
teacherInfo.setPreviousEmployeDetails(request.getParameter("prevdetails"));
//teacherInfo.setYearOfExper(Integer.parseInt(request.getParameter("experience")));
teacherInfo.setTeahcherPhoto(request.getParameter("photo"));
teacherInfo.setTeacherEmail(request.getParameter("email"));
System.out.println(tId);
System.out.println("TeacherId");
pupilInfoManagementBusinessService.createTeacherInfo(teacherInfo);
}catch (BusinessException e) {
webLayerLogger.error(CommonUtils.getStackTrace(e));
throw new UIException(e,UIMessageHelper.getLocalValue("exception while Inserting data"));
}
}
在读取所有值后,此方法将转到服务方法,这是服务类方法,
@Override
public void createTeacherInfo(TeacherInfo teacherInfo) throws BusinessException {
try {
pupilInfoManagementDataService.createTeacherInfo(teacherInfo);
}catch (Exception e) {
businessServiceLogger.error(CommonUtils.getStackTrace(e));
throw new BusinessException(this.getClass(), e, e.getMessage());
}
}
我的问题是值正在读取但不插入数据库。请帮助我。
答案 0 :(得分:0)
我打赌html表单包含照片的文件上传。当表单包含文件上传时,request.getParameter
将不再有效(值始终为null
)。当您执行文件上载时,您必须使用Apache Commons File Upload库从请求中检索参数,或者您可以使用request.getPart
(如果您使用的是最新版本的servlet容器)。