如何使用Hibernate和Struts 2将pdf文件检索到数据库中

时间:2018-10-06 07:50:00

标签: hibernate struts2

我已经完成了将文件保存到数据库中的操作,但是我不知道如何将文件保存到jsp文件中

public String save() throws IOException  {
        fileDAO dao = new fileDAO();

      File file = new File("F:\\");
        byte[] bFile = new byte[(int) file.length()];
     try {

       FileInputStream fileInputStream = new FileInputStream(file);
       fileInputStream.read(bFile);
        fileInputStream.close();
        } catch (Exception e) {
        e.printStackTrace();
    }
     //int userid=Integer.parseInt(request.getParameter("userid"));
     String username=request.getParameter("username");
    Fileupload fileupload = new Fileupload();
    fileupload.setUsername(username);
    fileupload.setUpload(bFile);
    dao.savefileinfo(fileupload);

0 个答案:

没有答案