jfinal文件上传和form表单值为null的解决方法

今天使用jfinal做上传提交的时候,遇到一个问题:添加了上传功能,原来的form表单submit提交时所有值都为null了,研究了很长时间,终于发现

在jfinal上传时候,jsp加

enctype="multipart/form-data"这句话的时候
<form id="form1" method="post" enctype="multipart/form-data" >

在后台接收时,必须第一个解决上传文件,然后再接收其他参数,就正常了,真是...啊

String path_tmp = "";

        String real_path = "";

        String fileName = "";

        String pathAndName = "";

        String uploadDir = File.separator + "upload" + File.separator + "contract" + File.separator;

        path_tmp = PathKit.getWebRootPath() + uploadDir;

        UploadFile uploadFile = getFile("upload", path_tmp);

        fileName = uploadFile.getFileName();

        real_path = uploadFile.getSaveDirectory();

        pathAndName = real_path + fileName;

        //申请部门id

        int department_id = getParaToInt("d_id");

 

你可能感兴趣的:(jFinal)