Jfinal getFile("xxxx").getUploadPath()无法获取到上传文件路径
采用的 是 Jfinal 框架 ,用jq ajax 上传文件
this.getfile(“xxxx”).getUploadPath() 想获上传文件的路径 ,总是无法获取到报错 空指针异常。 getPara("xxx")也无法获取到对应的参数。
前台代码
<form enctype ="multipart/form-data" id="upload">
<div class="bus-personal">
<div class="bus-personal-model"><span>姓名:</span><input name="userName" type="text" id="userName"></div>
<div class="bus-personal-model"><span>号码:</span><input name="userID" type="text" id="userId" ></div>
<div class="bus-personal-pic">
<ul id="warp" class="UP-warp">
<li>
<input type="file" id="up_img_WU_FILE_0" class="UP-file" name="Idcard_1">
<img src="images/sfz.png" width="150" height="100" id="imgShow_WU_FILE_0"/>
</li>
<li>
<input type="file" id="up_img_WU_FILE_1" class="UP-file" name="Idcard_2">
<img id="imgShow_WU_FILE_1" width="100" height="100" src="images/sfz1.png">
</li>
<li>
<input type="file" id="up_img_WU_FILE_2" class="UP-file" name="Idcard_3">
<img id="imgShow_WU_FILE_2" width="100" height="100" src="images/sfz2.png">
</li>
</ul>
</div>
</div>
</form>
ajax 传参数
//获取对应id的值
var userName = $("#userName").val();
var userID = $("#userId").val();
var file1 = $("#up_img_WU_FILE_0").val();
var file2 = $("#up_img_WU_FILE_1").val();
var file3 = $("#up_img_WU_FILE_2").val();
var data = new FormData();
data.append("userName", userName);
data.append("userID", userID);
data.append("file1",file1);
data.append("file2",file2);
data.append("file3",file3);
$.ajax({
url:"<%=basePath%>User/authenticationPersonal",
type:"post",
data:data,
dataTyep:"JSON",
cache:false, //禁止浏览器对该URL(以及对应的HTTP方法)的缓存
contentType:false, //禁止jQuery的转换操作
processData:false, //不需要对数据做处理
success:function(data){
layerOpen("test");
},
error:function(){
layerOpen("error");
}
});
后台获取参数 所有表单提交过去到后台的参数 都为空 ,无法获取参数。
//文件路径
String filePath1 = this.getFile("Idcard_1").getUploadPath();
String filePath2 = this.getFile("Idcard_2").getUploadPath();
String filePath3 = this.getFile("Idcard_3").getUploadPath();
String name = this.getPara("userName");
String idcardNo = this.getPara("userID");
代码