HibernateSpringStruts2ExtJS开发CRUD功能Word格式文档下载.docx

上传人:b****7 文档编号:22651868 上传时间:2023-02-05 格式:DOCX 页数:43 大小:160.44KB
下载 相关 举报
HibernateSpringStruts2ExtJS开发CRUD功能Word格式文档下载.docx_第1页
第1页 / 共43页
HibernateSpringStruts2ExtJS开发CRUD功能Word格式文档下载.docx_第2页
第2页 / 共43页
HibernateSpringStruts2ExtJS开发CRUD功能Word格式文档下载.docx_第3页
第3页 / 共43页
HibernateSpringStruts2ExtJS开发CRUD功能Word格式文档下载.docx_第4页
第4页 / 共43页
HibernateSpringStruts2ExtJS开发CRUD功能Word格式文档下载.docx_第5页
第5页 / 共43页
点击查看更多>>
下载资源
资源描述

HibernateSpringStruts2ExtJS开发CRUD功能Word格式文档下载.docx

《HibernateSpringStruts2ExtJS开发CRUD功能Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《HibernateSpringStruts2ExtJS开发CRUD功能Word格式文档下载.docx(43页珍藏版)》请在冰豆网上搜索。

HibernateSpringStruts2ExtJS开发CRUD功能Word格式文档下载.docx

filter-class>

org.apache.struts2.dispatcher.FilterDispatcher<

/filter-class>

/filter>

filter-mapping>

url-pattern>

/*<

/url-pattern>

<

/filter-mapping>

和Spring的配置:

context-param>

param-name>

contextConfigLocation<

/param-name>

param-value>

/WEB-INF/spring/*.xml<

/param-value>

/context-param>

listener>

 

listener-class>

org.springframework.web.context.ContextLoaderListener<

/listener-class>

/listener>

Web.xml的全部文件:

?

xmlversion="

1.0"

encoding="

UTF-8"

>

web-appid="

WebApp_ID"

version="

2.4"

xmlns="

xmlns:

xsi="

//www.w3.org/2001/XMLSchema-instance"

xsi:

schemaLocation="

display-name>

/display-name>

!

--SpringApplicationContext配置文件的路径,可使用通配符*,多个路径用,号分隔,此参数用于后面的Spring-Contextloader-->

--著名CharacterEncodingfilter-->

encodingFilter<

org.springframework.web.filter.CharacterEncodingFilter<

init-param>

encoding<

UTF-8<

/init-param>

--struts2滤镜配置 

-->

--SpringApplicationContext载入,必须-->

--Spring刷新Introspector防止内存泄露-->

org.springframework.web.util.IntrospectorCleanupListener<

--session超时定义,单位为分钟-->

session-config>

session-timeout>

10<

/session-timeout>

/session-config>

welcome-file-list>

welcome-file>

index.html<

/welcome-file>

index.htm<

index.jsp<

default.html<

default.htm<

default.jsp<

/welcome-file-list>

/web-app>

(2)Hibernate配置:

DOCTYPEhibernate-configurationPUBLIC

"

-//Hibernate/HibernateConfigurationDTD3.0//EN"

hibernate-configuration>

session-factory>

—-数据库驱动类名称-->

propertyname="

hibernate.connection.driver_class"

oracle.jdbc.driver.OracleDriver<

/property>

—-数据库用户名-->

hibernate.connection.username"

MY<

hibernate.default_schema"

—-数据库用户密码-->

hibernate.connection.password"

—-数据库连接字符串-->

hibernate.connection.url"

jdbc:

oracle:

thin:

@localhost:

1521:

loon<

hibernate.dialect"

org.hibernate.dialect.Oracle9Dialect<

—-控制台是否输出SQL语句-->

hibernate.show_sql"

true<

mappingclass="

privilege.database.Level"

/>

/session-factory>

/hibernate-configuration>

(3)Spring基本配置:

配置文件应该在WEB-INF/spring/下面

DOCTYPEbeansPUBLIC"

-//SPRING//DTDBEAN//EN"

//www.springframework.org/dtd/spring-beans.dtd"

beansdefault-autowire="

autodetect"

—如果用的是XML配置文件,sessionFactory用这个配置"

org.springframework.orm.hibernate3.LocalSessionFactoryBean"

beanid="

sessionFactory"

class="

org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"

configLocation"

value>

classpath:

hibernate.cfg.xml<

/value>

-- 

配置多个hibernate.cfg.xml

configLocations"

list>

hibernate_admin1.cfg.xml<

hibernate_admin2.cfg.xml<

/list>

/bean>

--Hibernate事务管理 

transactionManager"

org.springframework.orm.hibernate3.HibernateTransactionManager"

ref="

baseTransactionProxy"

org.springframework.transaction.interceptor.TransactionProxyFactoryBean"

abstract="

true"

transactionAttributes"

props>

propkey="

find*"

PROPAGATION_REQUIRED,readOnly<

/prop>

persist*"

PROPAGATION_REQUIRED,-Exception<

remove*"

--

insert*"

PROPAGATION_REQUIRED<

save"

update*"

edit*"

del*"

get*"

query*"

disPlay*"

PROPAGATION_REQUIRES_NEW<

/props>

LevelService"

parent="

target"

beanclass="

privilege.service.LevelService"

dao"

privilege.dao.LevelDAO"

LevelAction"

privilege.action.LevelAction"

levelService"

/beans>

(4)struts.xml文件的配置:

DOCTYPEstrutsPUBLIC 

-//ApacheSoftwareFoundation//DTDStrutsConfiguration2.0//EN"

//struts.apache.org/dtds/struts-2.0.dtd"

struts>

packagename="

privilege"

extends="

struts-default"

actionname="

LoadLevel"

method="

findLevelById"

result>

/resource/json_struts2.jsp<

/result>

/action>

LevelAjaxJsonData"

jsonExecute"

/package>

/struts>

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

importjavax.persistence.Column;

importjavax.persistence.Entity;

importjavax.persistence.Id;

importjavax.persistence.Table;

@Entity

@Table(name="

LOON_LEVEL"

publicclassLevelimplementsjava.io.Serializable{

privateLonglevelid;

privateStringlevelname;

privateStringdescription;

publicLevel(){

}

publicLevel(Longlevelid){

this.levelid=levelid;

publicLevel(Longlevelid,Stringlevelname,Stringdescription){

this.levelname=levelname;

this.description=description;

@Id

@Column(name="

LEVELID"

unique=true,nullable=false,precision=5,scale=0)

publicLonggetLevelid(){

returnthis.levelid;

publicvoidsetLevelid(Longlevelid){

LEVELNAME"

length=64)

publicStringgetLevelname(){

returnthis.levelname;

publicvoidsetLevelname(Stringlevelname){

DESCRIPTION"

length=256)

publicStringgetDescription(){

returnthis.description;

publicvoidsetDescription(Stringdescription){

}

ILevelDAO.java

importjava.util.List;

publicinterfaceILevelDAO{

publicLevelfindLevelById(Longid);

publicList<

Level>

findAllLevels();

publicvoidpersistLevel(Levellevel);

publicvoidremoveLevel(Levellevel);

publicvoidremoveById(Longid);

LevelDAO.java

importorg.hibernate.Session;

importorg.springframework.orm.hibernate3.HibernateCallback;

importorg.springframework.orm.hibernate3.support.HibernateDaoSupport;

publicclassLevelDAOextendsHibernateDaoSupportimplementsILevelDAO{

publicLevelDAO(){

super();

publicLevelfindLevelById(Longid){

return(Level)getHibernateTemplate().get(Level.class,id);

findAllLevels(){

returngetHibernateTemplate().loadAll(Level.class);

//.find("

fromLevelo"

);

//

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 经管营销 > 生产经营管理

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1