我在获取以下属性接受图像时获得空值。为什么?

时间:2015-09-09 13:21:39

标签: java image jsp servlets upload

你好每个人在获取name,lastname等值时获取null值。 但我的图片上传进展顺利,图像被移动或存储到所需的位置....请帮助这是我的代码

public void doPost(HttpServletRequest req,HttpServletResponse res)     {         fileItem = initRequest(req);

    name=req.getParameter("name");
    middlename=req.getParameter("middlename");
    lastname=req.getParameter("lastname");
    age=21;
    //age=Integer.parseInt(req.getParameter("age"));
    gender=req.getParameter("gender");
    email=req.getParameter("email");
    mobno=req.getParameter("mobno");
    religion=req.getParameter("religion");
    nationality=req.getParameter("nationality");
    username=req.getParameter("username");
    password=req.getParameter("password");
    rstatus=req.getParameter("rstatus");
    System.out.println(req.getParameter("rstatus"));
    File file = uploadFile(fileItem,"G://Friendbook//pictures");

    try 
    {
        ps=con.prepareStatement("insert into mem_info values(?,?,?,?,?,?,?,?,?,?,?,?,?)");
        ps.setString(1,name);
        ps.setString(2, middlename);
        ps.setString(3, lastname);
        ps.setInt(4,age);
        ps.setString(5, gender);
        ps.setString(6, email);
        ps.setString(7, mobno);
        ps.setString(8, religion);
        ps.setString(9, nationality);
        ps.setString(10, username);
        ps.setString(11, password);
        ps.setString(12, rstatus);
        ps.setString(13,file.getName());

        System.out.println("file name "+file.getName());
        int result=ps.executeUpdate();

        if (result > 0)
        {
            System.out.println("Ragistration successfull");
        }
        else
        {
            System.out.println("Ragistration failed");
        }
    }

    catch(Exception e1)
    {
        e1.printStackTrace();
    }

}

0 个答案:

没有答案