struts2 jquery ajaxfileupload 插件对返回的json下载问题!!

wyks521 2011-04-13 06:38:24
*.java
public String uploadimghead() throws IOException{
user = (User) ActionContext.getContext().getSession().get("user");
PrintWriter out = ServletActionContext.getResponse().getWriter();
try {

if(user!=null){
if(file!=null){
String fileSuffix = fileFileName.substring(this.fileFileName.lastIndexOf("."),fileFileName.length());
String s = "upload/user/temp-head/";
String url = context.getRealPath("/");
String fileName = ImgUpload.uploadImage(file, fileSuffix, url+s, user.getId());
ImgUpload.alterSize(url+s+fileName,url+s,fileName,300,275);//图片比例缩放下
ActionContext.getContext().getSession().put("temp-head", fileName);

out.write(s+fileName);
out.flush();
out.close();
}
}else{
out.write("nouser");//用户不存在
out.flush();
out.close();
}
} catch (Exception e) {
out.write("error");
out.flush();
out.close();
}finally{
return "success";
}
}


*.js

$.ajaxFileUpload({
url:"user/reg!uploadimghead.json?s"+new Date().valueOf(),
secureuri:false,
dataType: 'json',
fileElementId:"file1",
success: function (data, status)
{
var t = $(data).text();
if(t!="error"||t!="nouser"){//服务器错误
if(t==""){
regHeadModefind(data);//头像设置
}else{
regHeadModefind(t);//头像设置
}
resetUpload1(); //头像上传成功
}else{
$('#msgsuccess').html("");
$('#msgerror').html('头像上传失败!请重新上传图片!');
location.href="user!manager?vid=info";//刷新页面
}
}, error: function (data, status, e)
{
alert("上传失败...");
}
})

返回json下载问题!!!!!!!!!

我的QQ是348059300在线等!!!!!!!!!!
...全文
322 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
wyks521 2011-04-13
  • 打赏
  • 举报
回复
我的QQ是348059300在线等!!!!!!!!!!

67,549

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧