有了上传图片控件后 在action 中必须写上以下代码
- response.setCharacterEncoding("utf-8");
- response.setContentType("text/html");
// action代码
public String load4() {
System.out.println("获取到了abcd:"+abcd);
success = "true";
upload.upload("abcdefg.jpg", abcd,
"C:\\Program Files\\Apache Software Foundation\\Tomcat 6.0\\webapps\\needMovie\\"
+"testImage" + "\\");
Watch watch = new Watch();
watch.setNum(1);
watch.setOnLine("asdfasdf");
videoManager.save();
JSONObject jo = JSONObject.fromObject(watch);
String jsonStr = jo.toString();
System.out.println(jsonStr);
response.setCharacterEncoding("utf-8");
response.setContentType("text/html");
try {
// 返回成功标识
//response.getWriter().println("{success:true}");
response.getWriter().println("{success:true,watch:"+jsonStr+"}");
response.getWriter().flush();
//response.getWriter().notify();
} catch (IOException e) {
e.printStackTrace();
}
finally {
try {
response.getWriter().close();
} catch (IOException e) {
e.printStackTrace();
}
}
System.out.println("插入成功");
return null;
}
// 前台代码
artist: {
xtype: 'panel', // since we are not using the default 'panel' xtype,
// we must specify it
title:'登录',
width:350,
id:'artist-panel',
items:[{
xtype:'form',
id:'artist-form',
defaultType:'textfield',
bodyStyle : 'padding:5px',
method:'POST',
defaults:{
anchor:'95%',
},
items:[{
id:'loginName',
name:'loginName',
fieldLabel:'用户名',
},{
id:'password',
name:'password',
fieldLabel:'密码',
},{
xtype: 'filefield',
id: 'abcd',
emptyText: 'Select an image',
fieldLabel: 'Photo',
name: 'abcd',
buttonText: 'asdfasdf',
}]
}],
buttons: [{
text: 'Save',
handler: function(){
var loginForm = Ext.getCmp('artist-form').form;
loginForm.doAction('submit', {
url:'save!load4.action',
method:'POST',
waitMsg:'正在登陆...',
timeout:10000,// 10秒超时,
// params:loginForm.getValues(),
success:function(form, action){
alert('登陆成功'+action.result.watch.onLine)
var isSuc = action.result.success;
if(isSuc) {
// 提示用户登陆成功
Ext.Msg.alert('消息', '登陆成功..');
}
},
failure:function(form, action){
alert('登陆失败');
}
});
}
}]
}
};
//XML 代码
<package name="ajax" extends="json-default">
<action name="save" class="com.junjun.television.web.VideoAction">
<result type="json" name="success"/>
</action>
</package>
分享到:
相关推荐
Extjs4.0终极教程+案例源码(超详细,针对4.0) 目前最为卓越的4.0教程,还附加案例源码。白~吃,也能学会用extjs做页面
最完美的Extjs4.0中文资料+案例开发。
ExtJs + Struts2 + JSON 程序总结
Extjs Tree + JSON + Struts2 开发war包
extjs tree + json+struts2示例源代码extjs tree + json+struts2示例源代码
Extjs4.0+MVC模式+存动态加载,动态加载面板,动态加载控制器,动态加载树叶子节点,后台servlet模拟json数据
Extjs Tree + JSON + Struts2 例子
第三讲:extjs4.0数据模型--Model(附件较大做了分包压缩大家只要下载2个包运行001就ok了) [03]EXTJS4.0数据模型-Model.001.zip (70.00M)[03]EXTJS4.0数据模型-Model.002.zip (57.37M) 第四讲:extjs4.0的数据代理-...
Extjs4+MVC+struts2后台管理系统,
Extjs Tree + JSON + Struts2 示例源代码
extjs4.0+extdesign+fullsource+extjs.jsb2的整套开发.
extjs+struts2+hibernate+json登录程序,主要讲解struts2配置JSON与前台extjs通信,异步数据交换,很强大
NULL 博文链接:https://z-p-h.iteye.com/blog/1529957
Hibernate+Struts2+ExtJs4.0,采用json做数据传输做的小例子
ExtJs4.2+Mysql+Struts2+Hibernate3实现分页查询 1.libs目录缺少hibernate核心jar包 2.libs目录缺少struts jar 3.WebRoot目录缺少ExtJs4.2核心类库 以上信息我都在项目里面注明了,因为这些内容的文件太大了,CSDN不...
Extjs4登录功能+验证码+struts2
extjs4.2+ibatis+struts 构建的日程表插件 在原生前端的基础上修改为前后结合的ajax版本
网上有些这样的例子,但是下了几个都没有跑起来,哎,希望那些发文章的人要发就发全的,别发个半生不熟的。... 现在自己整理了一个Struts2+ExtJS2实现文异步文件上传,没法上传图片无法看到效果,直接上源码吧。
ExtJSweb 开发指南中的 简单图书管理系统 ExtJS3.0+spring+hibernate+struts