HibernateSpringStruts2ExtJS开发CRUD功能Word格式文档下载.docx
- 文档编号:22651868
- 上传时间:2023-02-05
- 格式:DOCX
- 页数:43
- 大小:160.44KB
HibernateSpringStruts2ExtJS开发CRUD功能Word格式文档下载.docx
《HibernateSpringStruts2ExtJS开发CRUD功能Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《HibernateSpringStruts2ExtJS开发CRUD功能Word格式文档下载.docx(43页珍藏版)》请在冰豆网上搜索。
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"
);
//
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- HibernateSpringStruts2ExtJS 开发 CRUD 功能
![提示](https://static.bdocx.com/images/bang_tan.gif)
链接地址:https://www.bdocx.com/doc/22651868.html