ajaxFileUpload上传文件时,后台action不执行也不报错,回调函数的success
$("#buttonUpload").click(function(){
$.ajaxFileUpload({
url:'/uploadLicense.action',
secureuri:false,
fileElementId:'fileToUpload',
dataType:'text',
success:function(data){
if(data.indexOf("ok") != -1){
alert(data);
// alert("授权成功!");
window.parent.location.href="/pages/common/login.jsp";
}
else{
alert(data);
}
},
error:function(){
}
});
//return false;
});
<input id="fileToUpload" type="file" size="20" name="Filedata" >
<button id="buttonUpload">上传</button>
上面是我的请求上传文件的代码,下面是后台的action,在action的类中,我也设置了Filedata的set和get方法了,以前都是这样用的,现在突然不行了,希望大家帮帮忙啊
@Action(value="uploadLicense")
public void uploadLicense() throws IOException{
//存放到指定目录
FileOutputStream fos = null;
FileInputStream fis = null;
try {
fos = new FileOutputStream(SystemInit.getRootPath()+"license/licence.xml");
fis = new FileInputStream(Filedata);
IOUtils.copy(fis, fos);
fos.flush();
fos.close();
fis.close();
} catch (Exception e) {
e.printStackTrace();
}
//验证license
String result = ScmsUtil.checkLicense();
//Struts2Utils.renderText(result);
response.setCharacterEncoding("utF-8");
PrintWriter out = response.getWriter();
out.write(result);
}