没有合适的资源?快使用搜索试试~ 我知道了~
Hibernate+Spring+Struts2+ExtJS开发CRUD功能
需积分: 9 66 浏览量
2011-10-21
16:50:37
上传
评论 1
收藏 347KB DOC 举报
Hibernate+Spring+Struts2+ExtJS开发CRUD功能Hibernate+Spring+Struts2+ExtJS开发CRUD功能Hibernate+Spring+Struts2+ExtJS开发CRUD功能Hibernate+Spring+Struts2+ExtJS开发CRUD功能Hibernate+Spring+Struts2+ExtJS开发CRUD功能
资源推荐
资源详情
资源评论












Hibernate+Spring+Struts2+ExtJS 开发 CRUD 功能
新一篇 : 学习 Hibernate JPA
1、 入门:
各种开源框架环境及下载:
Hibernate:3.x hp://www.hibernate.org/ 需要hibernate core 和annotaons 包。
Spring:2.x hp://springframework.org/
Struts2:2.x hp://struts.apache.org/2.x/
ExtJS:2.X hp://extjs.com/
JSON : JSON 可 以 到 hp://www.json.org/ 查 看 详 细 内 容 , 这 里 使 用 json-lib hp://json-
lib.sourceforge.net/
本所需要的包:
2、 配置:

(1)首先是配置web.xml,配置方法可以在下面的配置文件代码注释中查看,这里主要是Stru
ts2的配置:
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-
class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<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的全部文件:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>struts2</display-name>
<!-- Spring ApplicationContext配置文件的路径,可使用通配符*,多个路径用,号分隔,此参数
用于后面的Spring-Context loader -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/*.xml</param-value>

</context-param>
<!-- 著名 Character Encoding filter -->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</
filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<!-- struts2 滤镜配置 -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-
class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!--Spring ApplicationContext 载入 ,必须-->
<listener> <listener-
class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Spring 刷新Introspector防止内存泄露 -->
<listener>
<listener-class>org.springframework.web.util.IntrospectorCleanupListener</
listener-class>

</listener>
<!-- session超时定义,单位为分钟 -->
<session-config>
<session-timeout>10</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
(2)Hibernate配置:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!—-数据库驱动类名称 -->
<property
name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</
property>
<!—-数据库用户名 -->
<property name="hibernate.connection.username">MY</property>
<property name="hibernate.default_schema">MY</property>
<!—-数据库用户密码 -->
<property name="hibernate.connection.password">MY</property>
<!—-数据库连接字符串-->

<property
name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:loon</property>
<property
name="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</property>
<!—-控制台是否输出SQL语句 -->
<property name="hibernate.show_sql">true</property>
<mapping class="privilege.database.Level" />
</session-factory>
</hibernate-configuration>
(3)Spring基本配置:配置文件应该在WEB-INF/spring/下面
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-autowire="autodetect">
<!— 如 果 用 的 是 XML 配 置 文 件 , sessionFactory 用 这 个 配 置
"org.springframework.orm.hibernate3.LocalSessionFactoryBean" -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBea
n">
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
<!-- 配置多个hibernate.cfg.xml
<property name="configLocations">
<list>
<value>classpath:hibernate_admin1.cfg.xml</value>
<value>classpath:hibernate_admin2.cfg.xml</value>
</list>
</property>
-->
</bean>
<!-- Hibernate 事务管理 -->
剩余37页未读,继续阅读
资源评论

xiaowenhui2012
- 粉丝: 0
- 资源: 2

上传资源 快速赚钱
我的内容管理 收起
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助

会员权益专享
安全验证
文档复制为VIP权益,开通VIP直接复制
