- 浏览: 213408 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
q10000000:
你好 适用madMadia点击上传到服务器 没有反应啊LZ
在项目中整合FCKeditor文本编辑器 -
liweixxxx1990:
spring本版是3.0的(和版本也有关系吗?) 配置用到了s ...
struts2+spring发送mail -
floger:
liweixxxx1990 写道我照着你这个写的出现了下面的错 ...
struts2+spring发送mail -
liweixxxx1990:
我照着你这个写的出现了下面的错误,怎么解决啊??:Messag ...
struts2+spring发送mail -
jueyue:
不错,把问题解决了
Myeclipse下java.lang.OutOfMemoryError: Java heap space的解决
3、 建立的项目目录: Root: /resource/ext2.0/ 将下载的ext-2.0-beta1.zip文件解压到该目录 /WEB-INF/web.xml /WEB-INF/lib /WEB-INF/classes/struts.xml /WEB-INF/spring/applicationContext.xml 4、 代码清单: Level.java import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; @Entity @Table(name = "LOON_LEVEL") public class Level implements java.io.Serializable { private Long levelid; private String levelname; private String description; public Level() { } public Level(Long levelid) { this.levelid = levelid; } public Level(Long levelid, String levelname, String description) { this.levelid = levelid; this.levelname = levelname; this.description = description; } @Id @Column(name = "LEVELID", unique = true, nullable = false, precision = 5, scale = 0) public Long getLevelid() { return this.levelid; } public void setLevelid(Long levelid) { this.levelid = levelid; } @Column(name = "LEVELNAME", length = 64) public String getLevelname() { return this.levelname; } public void setLevelname(String levelname) { this.levelname = levelname; } @Column(name = "DESCRIPTION", length = 256) public String getDescription() { return this.description; } public void setDescription(String description) { this.description = description; } } ILevelDAO.java import java.util.List; public interface ILevelDAO { public Level findLevelById(Long id); public List<Level> findAllLevels(); public void persistLevel(Level level); public void removeLevel(Level level); public void removeById(Long id); } LevelDAO.java import java.util.List; import org.hibernate.Session; import org.springframework.orm.hibernate3.HibernateCallback; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; public class LevelDAO extends HibernateDaoSupport implements ILevelDAO { public LevelDAO() { super(); } public Level findLevelById(Long id) { return (Level) getHibernateTemplate().get(Level.class, id); } public List<Level> findAllLevels() { return getHibernateTemplate().loadAll(Level.class);// .find("from Level o");// } public void persistLevel(Level level) { getHibernateTemplate().saveOrUpdate(level); } public void removeLevel(Level level) { getHibernateTemplate().delete(level); } public void removeById(final Long id) { this.getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) { session.createQuery("delete from Level o where o.levelid=" + id + "").executeUpdate(); return 1; } }); } } ILevelService.java import java.util.List; public interface ILevelService { public Level findLevelById(Long id) throws Exception; public List<Level> findAllLevels() throws Exception; public List<Level> findLevelsByExample(Level level) throws Exception; public void persistLevel(Level level) throws Exception; public void removeLevel(Level level) throws Exception; public void removeLevelById(Long id) throws Exception; } LevelService.java import java.util.List; import privilege.dao.*; import privilege.database.Level; import org.springframework.context.ApplicationContext; public class LevelService implements ILevelService { private ILevelDAO dao; private static final String SERVICE_BEAN_ID = "LevelService"; public LevelService() { super(); } public static ILevelService getInstance(ApplicationContext context) { return (ILevelService) context.getBean(SERVICE_BEAN_ID); } public Level findLevelById(Long id) throws Exception { try { return getDao().findLevelById(id); } catch (RuntimeException e) { throw new Exception("findLevelById failed with the id " + id + ": " + e.getMessage()); } } public void persistLevel(Level level) throws Exception { try { getDao().persistLevel(level); } catch (RuntimeException e) { throw new Exception("persistLevel failed: " + e.getMessage()); } } public void removeLevel(Level level) throws Exception { try { getDao().removeLevel(level); } catch (RuntimeException e) { throw new Exception("removeLevel failed: " + e.getMessage()); } } public void removeLevelById(Long id) throws Exception { try { getDao().removeById(id); } catch (RuntimeException e) { throw new Exception("removeLevel failed: " + e.getMessage()); } } public void setDao(ILevelDAO dao) { this.dao = dao; } public ILevelDAO getDao() { return this.dao; } } ExtJSONActionSuport.java 辅助类,继承了ActionSupport import com.opensymphony.xwork2.ActionSupport; public class ExtJSONActionSuport extends ActionSupport { private int totalCount = 0;// 总数 private transient int start = 0;// 开始数 private transient int limit = 0;// 限制数量 private String jsonString = ""; public String getJsonString() { return jsonString; } public void setJsonString(String jsonString) { this.jsonString = jsonString; } public String jsonExecute() throws Exception { return super.execute(); } public int getTotalCount() { return totalCount; } public void setTotalCount(int totalCount) { this.totalCount = totalCount; } public int getStart() { return start; } public void setStart(int start) { this.start = start; } public int getLimit() { return limit; } public void setLimit(int limit) { this.limit = limit; } } LevelAction.java import java.util.List; import java.util.ArrayList; import javax.servlet.http.HttpSession; import org.apache.struts2.ServletActionContext; import net.sf.json.JSONArray; import privilege.database.Level; import privilege.service.*; import commons.utils.action.ExtJSONActionSuport; public class LevelAction extends ExtJSONActionSuport { private static final long serialVersionUID = 1L; private Level level = null; private List<Level> levels = new ArrayList<Level>(0); private ILevelService levelService = null; private String delData; public String execute() { return this.SUCCESS; } @Override public String jsonExecute() throws Exception { if (this.getDelData() != null && !"".equals(this.getDelData())) { if (this.getDelData().indexOf(",") < 0) { this.levelService.removeLevelById(Long.parseLong(this.getDelData())); System.out.println("del_id:" + getDelData()); } else { String id[] = this.getDelData().split(","); for (int i = 0; i < id.length; i++) { System.out.println("del:" + id[i]); this.levelService.removeLevelById(Long.parseLong(id[i])); } } } HttpSession session = ServletActionContext.getRequest().getSession(); Object o = null;// session.getAttribute("Level_Data1"); if (o == null) { try { this.levels = this.getLevelService().findAllLevels(); session.setAttribute("Level_Data1", this.levels); System.out.println("query database"); } catch (Exception e) { e.printStackTrace(); } } else { this.setLevels(((List<Level>) o)); } this.setTotalCount(this.levels.size()); JSONArray array = JSONArray.fromObject(this.levels); // System.out.println(this.getStart() + "---" + this.getLimit()); this.setJsonString("{success:true,totalCount : " + this.getTotalCount() + ", list:" + array.toString() + "}"); // System.out.println(this.getJsonString()); return super.jsonExecute(); } /** * Find an entity by its id (primary key). * * @param id * @return The found entity instance or null if the entity does not exist. */ public String findLevelById(Long id) { try { this.level = this.getLevelService().findLevelById(id); } catch (Exception e) { e.printStackTrace(); } JSONArray array = JSONArray.fromObject(this.levels); this.setJsonString(array.toString()); return SUCCESS; } public String findLevelById() { System.out.println(this.level.getLevelid()); try { this.level = this.getLevelService().findLevelById(this.level.getLevelid()); } catch (Exception e) { e.printStackTrace(); } JSONArray array = JSONArray.fromObject(this.level); this.setJsonString(array.toString()); this.setJsonString("{success:true,totalCount:1,list:" + array.toString() + "}"); System.out.println(array.toString()); return SUCCESS; } /** * @return Return all persistent instances of the <code>Level</code> entity. */ public String getAllLevels() { try { this.levels = this.getLevelService().findAllLevels(); } catch (Exception e) { e.printStackTrace(); } return SUCCESS; } /** * Make the given instance managed and persistent. * * @return */ public String persistLevel() { System.out.println(this.level.getLevelid() + "---" + this.level.getLevelname() + "---" + this.level.getDescription()); this.setJsonString("{success:true}"); try { this.getLevelService().persistLevel(this.getLevel()); } catch (Exception e) { e.printStackTrace(); } return SUCCESS; } /** * Remove the given persistent instance. * * @return */ public String removeLevel() { try { this.getLevelService().removeLevel(this.getLevel()); } catch (Exception e) { e.printStackTrace(); } return SUCCESS; } /** * Remove an entity by its id (primary key). * * * @return */ public String removeLevelById(Long id) { try { this.getLevelService().removeLevelById(id); } catch (Exception e) { e.printStackTrace(); } return SUCCESS; } public Level getLevel() { return level; } public void setLevel(Level level) { this.level = level; } public List<Level> getLevels() { return levels; } public void setLevels(List<Level> levels) { this.levels = levels; } public ILevelService getLevelService() { return levelService; } public void setLevelService(ILevelService levelService) { this.levelService = levelService; } public String getDelData() { return delData; } public void setDelData(String delData) { this.delData = delData; } }
发表评论
-
ext lovcombo的使用
2010-02-24 11:47 2455如下LovCombo.js / ... -
Ext JS 中实现自定义验证 密码修改 确认密码
2010-02-21 17:01 3421EXT中有自带的验证,比如数字,EMAIL,URL等,这 ... -
Ext中经常用到的VTypes的自定义扩展集。
2010-02-21 16:27 948在Ext中,经常会遇到这样或那样的数据类型,比如时间型、 ... -
整合EXT JS 和 SSH2框架
2009-07-20 17:25 3090提出一种将EXT JS作为展示层技术如何整合到SSH2框架 ... -
Hibernate+Spring+Struts2+ExtJS开发CRUD功能(3)
2009-07-02 11:20 2516配置spring,添加: <bean id=&qu ... -
Hibernate+Spring+Struts2+ExtJS开发CRUD功能(1)
2009-07-02 11:16 2014Hibernate+Spring+Struts2+ExtJS开 ...
相关推荐
Hibernate+Spring+Struts2+ExtJS开发CRUD功能
在IT行业中,构建Web应用程序是常见的任务,而“Hibernate+Spring+Struts2+ExtJS开发CRUD功能实例”提供了一个完整的解决方案,用于快速开发基于Java的Web应用,特别是涉及数据库操作的CRUD(创建、读取、更新、删除...
Hibernate+Spring+Struts2+ExtJS开发CRUD功能最新版lib[Zone Yan] 2个小时才找全的啊。
在"Hibernate+Spring+Struts2+ExtJS整合开发实例"中,开发者通常会利用这些框架的协同工作来实现CRUD(Create, Read, Update, Delete)操作,这是数据库应用的基本功能: 1. **创建(Create)**: 用户通过ExtJS的...
### Hibernate+Spring+Struts2+ExtJS集成开发CRUD功能 #### 一、技术栈介绍与环境搭建 **1. Hibernate:** Hibernate是一个强大的对象关系映射(ORM)框架,用于简化Java应用程序与数据库之间的交互。通过...
总结来说,整合Hibernate、Spring、Struts2和ExtJS可以构建出功能强大且用户体验良好的Web应用。通过CRUD操作和动态加载树,我们可以有效地管理复杂的数据结构,为用户提供直观的交互界面。在实际开发中,还需要根据...
标题中的"Hibernate+Spring+Struts2+ExtJS"是一个经典的Java Web开发框架组合,也被称为SSH2(Struts2, Spring, Hibernate)与ExtJS的集成。这个组合在过去的几年里广泛应用于企业级应用开发,提供了强大的数据持久...
这是一个基于Java技术栈的Web应用实例,名为...总之,这个实例是一个典型的Java Web项目,通过集成Struts2、Spring、Hibernate和ExtJS,实现了音乐播放器的功能,对于学习和理解这些技术的结合使用具有很高的参考价值。
【图书管理系统源码(ExtJs+struts2+hibernate+spring)】是一个基于Web的软件项目,它展示了如何整合多种技术来构建一个实际的应用系统。这个管理系统使用了前端框架ExtJs,后端MVC框架Struts2,持久层框架...
### Struts2+Spring+Hibernate+ExtJS集成开发详解 #### 一、技术栈概览与集成背景 在企业级应用开发中,采用MVC架构的项目常常会使用到多种框架来实现不同的业务需求,其中Struts2、Spring、Hibernate以及ExtJS是...
这是一个基于Java技术栈的Web应用开发案例集合,涵盖了ExtJS前端框架、Hibernate持久化框架、Struts2 MVC框架以及Spring框架的综合运用。这个源代码库对于初学者来说是一个宝贵的资源,可以帮助他们理解和掌握这些...
这个压缩包文件包含了一个基于J2EE架构的高级项目源码,主要采用了Struts2.0、Hibernate、Spring和ExtJS这四大核心技术。下面将详细解释这些技术及其在项目中的应用。 **Struts2.0** 是一个MVC(Model-View-...
这是一个基于Spring MVC、Hibernate和ExtJS的Web应用示例,主要展示了如何整合这三个技术来构建一个功能完善的后台管理系统。下面将分别对这三个技术及其整合方式进行详细介绍。 **Spring MVC** Spring MVC是Spring...
本项目名为"extjs2.0+struts1.2+hibernate+spring增删改查",结合了四个核心的技术框架,它们分别是ExtJS 2.0、Struts 1.2、Hibernate和Spring,用于实现数据的CRUD(创建、读取、更新和删除)操作。这四个组件共同...
Struts2.18+Spring2.56+Hibernate3+Extjs+JSON是一个经典的Java Web开发技术组合,常用于构建高效、可扩展的企业级应用。这个项目涉及到的知识点广泛,涵盖前端、后端以及数据持久化等多个层面。以下是这些技术在...