简体   繁体   English

从jsp页面读取值后发生异常

[英]Exception after reading values from jsp page

I am inserting values into database but I am getting UIException here is my code sample, 我正在将值插入数据库,但是我得到了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"));
                }
}

In this method after reading all values it will go to service method , Here is service class method, 在此方法中,读取所有值后将转到service方法,这是service类方法,

@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());
    }

}

My problem is values are reading but not inserting to database. 我的问题是值正在读取但未插入数据库。 Please help me in this . 请帮助我。

I'll bet the html form for this includes a file upload for the photo. 我敢打赌html表单会包含上传照片的文件。 When a form includes a file upload, then request.getParameter will not work any longer (the values will always be null ). 当表单包含文件上传时,那么request.getParameter将不再起作用(值始终为null )。 When you do a file upload you have to use Apache Commons File Upload library to retrieve the parameters from the request, or you can use request.getPart (if you are on the latest version of your servlet container). 上传文件时,必须使用Apache Commons File Upload库从请求中检索参数,或者可以使用request.getPart (如果您使用的是Servlet容器的最新版本)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM