- 浏览: 640019 次
- 性别:
- 来自: 合肥
文章分类
最新评论
-
nehaoww:
754588141@qq.com,源码可以给一份吗
Struts/JSP可上传、预览服务器端文件(图片、文件、Flash、多媒体)文件组件 -
zzd_md:
把XmlTreeLoader.js 这个文件的路径改一下就好了 ...
ExtJs 实现的后台管理框架 -
llixinrui_strive:
EXT之form.load(转) -
liangzhang0929:
部门管理和用户管理的url怎么显示#,没法打开dept_lis ...
Extjs3.x Struts2 -Json-plugin学习实例 -首页框架代码 05 -
datouren:
您好想问你一下 为什么只显示根节点 其它节点不显示 目前是在一 ...
ExtJs加载本地txt格式的数据
因为这是只学习项目,所以我没有使用数据库了,直接在Action模式几条数据了。如果使用数据库,那代码量就大了,而这个项目只是学习整合Struts2,所以不用,大家自己确定,
数据我是使用static来完成,只要服务器不重新启动,数据就会在,哈哈,方便呀……
如何大家真不想自己输入代码,就下载吧。见附件。
实际后台代码也是非常的简单,只有几个类User/Dept/UserAction/DeptAction
大家自己建立相应的包
代码如下:
1、Dept类
package com.wjt276.extjs.model; public class Dept { private int id; private String name; private String description; public Dept(int id, String name, String description) { super(); this.id = id; this.name = name; this.description = description; } public Dept() { super(); } //……我省了getter/setter方法,在项目中大家自己生成------ }
2、User
package com.wjt276.extjs.model; public class User { private int id; private String username; private String name; private String password; private boolean sex; private String phone; private String tel; private String url; private String email; private Dept dept; private String address; private String description; public User() { } public User(int id, String username, String name, String password, String phone, String tel, String url, String email, String address, boolean sex, String description) { super(); this.id = id; this.username = username; this.name = name; this.password = password; this.phone = phone; this.tel = tel; this.url = url; this.email = email; this.address = address; this.sex = sex; this.description = description; } //……我省了getter/setter方法,在项目中大家自己生成------ }
3、DeptAction
数据也是在这里生成的,我多加了几个对象,是为了在前台观查数据,可以不是太好,大家不要管它
package com.wjt276.extjs.action; import java.security.SecureRandom; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import com.opensymphony.xwork2.ActionSupport; import com.wjt276.extjs.model.Dept; @SuppressWarnings("serial") public class DeptAction extends ActionSupport { static SecureRandom random = new SecureRandom(); private Dept dept; private String msg; private boolean success; private int totalProperty; private List<Dept> depts = new ArrayList<Dept>(); private Map<Integer, Dept> deptsMap = new HashMap<Integer, Dept>(); private static List<Dept> lists = new ArrayList<Dept>(); private static Map<Integer, Dept> maps = new HashMap<Integer, Dept>(); static { Dept temp = new Dept(random.nextInt(100), "技术部", "技术……"); Dept temp1 = new Dept(random.nextInt(100), "技术部5", "技术…55…"); lists.add(temp); lists.add(temp1); maps.put(temp.getId(), temp); maps.put(temp1.getId(), temp1); } @Override public String execute() throws Exception { this.depts = lists; this.deptsMap = maps; this.success = true; this.totalProperty = this.depts.size(); return SUCCESS; } public String add() throws Exception { System.out.println(dept.getName() + "," + dept.getDescription()); Dept deptTemp = new Dept(random.nextInt(100),dept.getName(),dept.getDescription()); lists.add(deptTemp); maps.put(deptTemp.getId(),deptTemp); this.success = true; return this.execute(); } public String findDeptById(){ this.dept = maps.get(dept.getId()); this.success = this.dept != null; return SUCCESS; } public String delete() { return SUCCESS; } public String modify() throws Exception { if(this.dept == null){ this.success = false; this.msg = "数据不合法……"; } else { Dept tempDept = maps.get(dept.getId()); this.success = tempDept != null; if(this.success){ maps.put(this.dept.getId(), this.dept); for(int i = 0; i < lists.size(); i++){ Dept dept3 = (Dept)lists.get(i); if(this.dept.getId() == dept3.getId()){ lists.remove(i); lists.add(this.dept); System.out.println("找到"); break; } System.out.println(dept3.getId()); } return this.execute(); } else { this.msg = "数据记录不存在!"; } } return SUCCESS; } //-----------以下为Setter/getter方法-------------------------------------------------------------------------- public List<Dept> getDepts() { return depts; } public void setDepts(List<Dept> depts) { this.depts = depts; } public Dept getDept() { return dept; } public void setDept(Dept dept) { this.dept = dept; } public Map<Integer, Dept> getDeptsMap() { return deptsMap; } public void setDeptsMap(Map<Integer, Dept> deptsMap) { this.deptsMap = deptsMap; } public int getTotalProperty() { return totalProperty; } public void setTotalProperty(int totalProperty) { this.totalProperty = totalProperty; } public String getMsg() { return msg; } public void setMsg(String msg) { this.msg = msg; } public boolean isSuccess() { return success; } public void setSuccess(boolean success) { this.success = success; } public static List<Dept> getLists() { return lists; } public static Map<Integer, Dept> getMaps() { return maps; } }
4、UserAction
package com.wjt276.extjs.action; import java.security.SecureRandom; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.struts2.json.annotations.JSON; import com.opensymphony.xwork2.ActionSupport; import com.wjt276.extjs.model.Dept; import com.wjt276.extjs.model.User; @SuppressWarnings("serial") public class UserAction extends ActionSupport { static SecureRandom random = new SecureRandom(); private String ids; public String getIds() { return ids; } public void setIds(String ids) { this.ids = ids; } private String msg; private Dept dept; private boolean success; private int totalProperty; private User user; private List<User> users = new ArrayList<User>(); private Map<Integer,User> usersMap = new HashMap<Integer,User>(); private static List<User> lists = new ArrayList<User>(); private static Map<Integer,User> maps = new HashMap<Integer,User>(); static { User temp = new User(random.nextInt(100), "wjt276", "吴俊涛", "19831213", "05513238815", "18955113096", "http://wjt276.iteye.com", "wjt276@126.com", "安徽合肥淝河南路", true, "我是一名技术员" ); temp.setDept(DeptAction.getLists().get(0)); lists.add(temp); maps.put(temp.getId(), temp); } @Override public String execute() throws Exception { this.users = lists; this.usersMap = maps; this.success = true; this.totalProperty = this.users.size(); return SUCCESS; } public String add() throws Exception{ System.out.println(this.user.getUsername() + "," + this.user.getName()); this.user.setId(random.nextInt(100)); this.user.setDept(DeptAction.getMaps().get(this.dept.getId())); lists.add(this.user); maps.put(this.user.getId(),this.user); this.success = true; return this.execute(); } public String findUserById(){ this.user = maps.get(this.user.getId()); this.success = this.user != null; return SUCCESS; } public String delete() throws Exception{ if(this.ids != null && !"".equals(this.ids.trim())){ String[] id_s = this.ids.split(","); for(int i = 0; i < id_s.length; i++){ int id = Integer.parseInt(id_s[i]); System.out.println(id); for(int j = 0; j < lists.size(); j++){ User user3 = (User)lists.get(j); if(id == user3.getId()){ lists.remove(j); maps.remove(id); break; } } } } return this.execute(); } public String modify() throws Exception{ if(this.user == null){ this.success = false; this.msg = "数据不合法……"; } else { User tempUser = maps.get(this.user.getId()); this.success = tempUser != null; if(this.success){ maps.put(this.user.getId(), this.user); for(int i = 0; i < lists.size(); i++){ User user3 = (User)lists.get(i); if(this.user.getId() == user3.getId()){ lists.remove(i); this.user.setDept(DeptAction.getMaps().get(this.dept.getId())); lists.add(this.user); System.out.println("找到"); break; } System.out.println(user3.getId()); } return this.execute(); } else { this.msg = "数据记录不存在!"; } } return SUCCESS; } //-------------以下为getter/setter方法------------------------------------------------------------------ public static SecureRandom getRandom() { return random; } public static void setRandom(SecureRandom random) { UserAction.random = random; } public String getMsg() { return msg; } public void setMsg(String msg) { this.msg = msg; } public Dept getDept() { return dept; } public void setDept(Dept dept) { this.dept = dept; } public boolean isSuccess() { return success; } public void setSuccess(boolean success) { this.success = success; } public int getTotalProperty() { return totalProperty; } public void setTotalProperty(int totalProperty) { this.totalProperty = totalProperty; } public User getUser() { return user; } public void setUser(User user) { this.user = user; } public List<User> getUsers() { return users; } public void setUsers(List<User> users) { this.users = users; } public Map<Integer, User> getUsersMap() { return usersMap; } public void setUsersMap(Map<Integer, User> usersMap) { this.usersMap = usersMap; } }
- src.rar (4.1 KB)
- 下载次数: 272
发表评论
-
Ext.FormPanel 提交和 Ext.Ajax.request 异步提交函数的区别 - 转
2010-11-09 11:49 1982(1)Ext.FormPanel f.getForm() ... -
Ext formpanel submit 提交与ext.ajax.request提交的区别 - 转
2010-11-09 11:47 6245前置: 后台成功返回字符串:{success:tru ... -
Extjs textfield文件对齐方式
2010-11-07 14:11 8709ExtJs中的textfield文本对齐方式,没有直接的配置, ... -
ExtJS中数据源中的日期格式不组件接受的日期格式不一致时??
2010-11-06 13:14 4421在用ExtJS + struts2-json开发过程上发现日期 ... -
Extjs3.x Struts2 -Json-plugin学习实例 -User管理页面 - 完 07
2010-10-26 12:30 2475user_list.jsp <%@ page l ... -
Extjs3.x Struts2 -Json-plugin学习实例 -Dept管理页面 06
2010-10-26 12:28 2034dept_list.jsp <%@ pag ... -
Extjs3.x Struts2 -Json-plugin学习实例 -首页框架代码 05
2010-10-26 12:26 2427代码我就不多说了,不明白,看教程吧。我就贴出来好了。 ... -
Extjs3.x Struts2 -Json-plugin学习实例 -struts.xml配置 04
2010-10-26 12:21 2168struts.xml实际上也非常的简单,代码如下: 但 ... -
Extjs3.x Struts2 -Json-plugin学习实例 01
2010-10-26 12:02 2236我写下这个一是为了自己学习的整理,另一是为了其它入门的网友 ... -
Extjs3.x Struts2 -Json-plugin学习实例-搭建开发环境 02
2010-10-26 12:00 1975这里的项目开发环境与其它普通的开发环境一样,只是配置Strut ...
相关推荐
本Demo采用Struts2.1.8+Spring2.5.6(Annotation注解)+Hiberante3.3.2(Annotation注解)+ExtJS(Struts2-json)
使用ExtJs获取后台json格式的数据必须的七个jar包,commons-beanuti-1s-1.7.0.jar,commons-collections-3.1.jar,commons-lang-2.5.jar,commons-logging-1.0.4.jar,ezmorph-1.0.4.jar,json-lib-2.1.jar,...
struts2-extjs4.rar extjs4通过json和struts2进行交互的demo
将struts-2.1.6\lib目录下的struts2-codebehind-plugin-2.1.6.jar、struts2-core-2.1.6.jar、struts2-spring-plugin-2.1.6.jar、xwork-2.1.2.jar、ognl-2.6.11.jar、freemarker-2.3.13.jar、commons-fileupload-...
Extjs3.x入门学习指南,还附带一些常用控件属性的详细描述和使用说明
在我的随笔Extjs Tree + JSON + Struts2中我介绍了如何异步加载一个Extjs的树,但是很多网友留言说不能成功操作。现在我自己做了一个所有源代码的包,供大家下载。 有几点事项请大家注意 1、blogjava的文件上载要求...
iterator_jsonDemo1的链接:http://download.csdn.net/detail/cafebar123/8816409 运用了Extjs,Struts2, json,iterator技术, 将数据从后台传到Extjs表现层(自带json相关jar包)。注释详细,供参考。 Use ...
struts2 学习参考文档,spring 结合学习参考文档,希望对大家都有帮助
本系统所用框架 struts2 spring ibatis extjs 数据库采用sqlserver 实现图书基本管理功能,对学习这些框架的人来说是难得的资源,包占空间大大我没放进来,我把包的名称都写下来了,系统没有问题,配置跑不通自己好好...
ExtJS4+Accordion+SERVLET/STRUTS2+JSON+Ext.tree.Panel实例
帮大家整理整理一下 extjs3.x 官方大量示例 以及chm版api
最新版的maven私服安装包,nexus-3.27.0-03-win64.zip 。Nexus是一个强大的Maven仓库管理器,它极大地简化了自己内部仓库的维护和外部仓库的访问。利用Nexus你可以只在一个地方就能够完全控制访问 和部署在你所维护...
ExtJS3.x 中文帮助文档,是 CHM 格式的,方便阅读和查询。本人正在使用,效果不错,共享出来,方便大家。
Nexus是一套“开箱即用”的系统不需要数据库,它使用文件系统加Lucene来组织数据。Nexus 使用ExtJS来开发界面,利用Restlet来提供完整的REST APIs,通过m2eclipse与Eclipse集成使用。Nexus支持WebDAV与LDAP安全身份...
ExtJS+struts2+json登陆实例--源码,适合初学者
struts2 json extjs 完整实例 struts2 json extjs 完整实例 完整可用 无错! struts2 json extjs 完整实例 struts2 json extjs 完整实例 完整可用 无错! struts2 json extjs 完整实例 struts2 json extjs 完整...
ExtJs + Struts2 + JSON 程序总结
ExtJS2.X 版本app 这个版本目前找不到了噢
Struts2(json-plugin) + Spring2 + ExtJS2.2 开源网络硬盘系统
详细的介绍了EXT2.X各种对象的属性、方法、事件