action执行完应该显示提示,现在变成下载
我是用的SSH2框架+ExtJs,插入数据操作,action执行完没有弹出提示,而是成了提示下载,下载的文件用记事本打开的内容是应该弹出提示的内容页面JS代码
function uploadpicwin(gridzjtp){
//上传图片类型
var img_reg = /\.([jJ][pP][gG]){1}$|\.([jJ][pP][eE][gG]){1}$|\.([gG][iI][fF]){1}$|\.([pP][nN][gG]){1}$|\.([bB][mM][pP]){1}$/;
var txtupload = new Ext.form.TextField({fieldLabel:"上传图片",anchor:"90%",id :'upload',name:"upload",inputType:"file",blankText:'上传图片不能为空'});
var txtpiclx=new Ext.form.ComboBox({fieldLabel:"图片类型",resizable:true,anchor:"90%",name:"zjpicLxmc",hiddenName:'zjpicLx',valueField:'zjpicLx',displayField:'zjpicLxmc',mode:'local',triggerAction:'all', typeAhead:true,lazyRender:true,store:piczjlxstore,emptyText:'--请选择',forceSelection:true,allowBlank:false});
var form = new Ext.form.FormPanel({
frame:true,
url:'piczj_add.action',
method:'get',
style:'padding:10px',
buttonAlign: 'center',
bodyStyle:'padding:10px',
monitorValid:true,
labelAlign:"right",
labelWidth:70,
fileUpload: true,
items:[{
xtype:'fieldset',
title: '图片信息',
autoHeight:true,
items:[{
layout:"column",
items:[{
columnWidth:.5,
layout:"form",
items:[txtpiclx]
},{
columnWidth:1,
layout:"form",
items:[txtupload]
}]
}]
},{
xtype:'fieldset',
title: '图片预览',
autoHeight:true,
items:[{
xtype : 'box',
id : 'browseImage',
fieldLabel : "预览图片",
autoEl : {
width : 635,
height : 350,
tag : 'img',
// type : 'image',
src : Ext.BLANK_IMAGE_URL,
style : 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale);',
complete : 'off',
id : 'imageBrowse'
}
}]
}],
listeners : {
'render' : function(f) {
this.form.findField('upload').on('render', function() {
//通過change事件,图片也动态跟踪选择的图片变化
Ext.get('upload').on('change',
function(field, newValue, oldValue) {
//得到选择的图片路径
var url = 'file://'+ Ext.get('upload').dom.value;
if (img_reg.test(url)) {
if (Ext.isIE) {
var image = Ext.get('imageBrowse').dom;
image.src = Ext.BLANK_IMAGE_URL;// 覆盖原来的图片
image.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = url;
}// 支持FF
else {
Ext.get('imageBrowse').dom.src = Ext.get('upload').dom.files.item(0).getAsDataURL();
}
}
}, this);
}, this);
}
},
buttons:[{
text:'上传',
formBind:true,
handler:function (){
var url = Ext.get('upload').dom.value;
if (url == "" || url == null) {
Ext.MessageBox.alert("提示信息","请选择需要上传的图片");
return;
}
form.getForm().submit({
waitMsg:'数据保存中...',
params:{url:url},
success:function(form,response){
var responseText = eval("(" +response.response.responseText+ ")");
Ext.MessageBox.alert("提示信息",responseText.msg);
win_uploadImage.close();
gridzjtp.getStore().reload();
},
failure:function(form,response){
var responseText = eval("(" +response.response.responseText+ ")");
Ext.MessageBox.alert("提示信息",responseText.msg);
}
});
}
},{
text:'关闭',
handler:function(){
win_uploadImage.close();//hide();
}
}]
});
var win_uploadImage = new Ext.Window({
title:'图片管理',
id:'picWin',
width:700,
modal:true,
autoScroll : true,
height:580,
autoHeight:true,
items:[form]
});
win_uploadImage.show();
}
对应Action代码
public String add()
{
try{
HttpServletRequest request = (HttpServletRequest)ServletActionContext.getRequest();
MultiPartRequestWrapper wrapper = (MultiPartRequestWrapper) request;
String fileName = wrapper.getFileNames("upload")[0];
File srcfile = wrapper.getFiles("upload")[0];
String xh = xhService.getXh();
String picmc = xh+getFileExp(fileName);
String toSrc =SysConfig.readImgpath("/syscfg/imageallpath")+picmc;
File disFile = new File(toSrc);
FileUtils.copyFile(srcfile,disFile);
PicCvt.UploadPic(picmc);
WebPicZj pic = new WebPicZj();
pic.setZjpicDm(xh);
pic.setZjpicMc(picmc);
piczjService.saveorupdate(pic);
OutJson.outString("{success:true,msg:'保存成功!'}");
}catch(Exception e)
{
e.printStackTrace();
OutJson.outString("{success:false,msg:'保存失败,保存图片发生异常!'}");
}
return null;
}
原来应该弹出这个提示:
[img=http://www.baidupcs.com/thumbnail/10452887ad7ffa75a9002fb4f8c3fbc4?fid=3641020647-250528-2837898788&time=1368432224&rt=pr&sign=FDTAR-DCb740ccc5511e5e8fedcff06b081203-NLcPz232UkxIRgXzg94ot5vWueg%3D&expires=8h&size=c850_u580&quality=100][/img]
现在却弹出了这个:
[img=http://www.baidupcs.com/thumbnail/2861f7b19ddad6fcd9ae2020acbfc950?fid=3641020647-250528-1783535465&time=1368432386&rt=pr&sign=FDTAR-DCb740ccc5511e5e8fedcff06b081203-pKadNlulrulAq7cbNPIn6jyngzg%3D&expires=8h&size=c850_u580&quality=100][/img]
数据已经保存成功了, 就是没有提示,而且页面一直是数据保存中。
问问各位大神,这里面有什么问题吗?怎么才能弹出提示? --------------------编程问答-------------------- 为什么都没人回复,好忧桑啊。 --------------------编程问答-------------------- 意思你的success函数根本没进去,是吗?OutJson这个是全局变量? --------------------编程问答-------------------- OutJson是自定义的一个类
public class OutJson {
public static void outString(String string) {
PrintWriter out = null;
HttpServletResponse res = null;
try {
res = ServletActionContext.getResponse();
res.setContentType("text/javascript;charset=UTF-8");
out = res.getWriter();
out.write(string);
out.flush();
} catch (IOException e) {
e.printStackTrace();
}finally {
IOUtils.closeQuietly(out);
}
}
}
其他的action也都是这么写的,返回的都正常,就这个会出现这问题! --------------------编程问答-------------------- 原来应该弹出这个提示:
现在却弹出了这个:
补充:Java , Web 开发