SSH spring+struts2+hibernate整合步骤
来源:互联网 发布:淘宝女装店背景图 编辑:程序博客网 时间:2024/06/08 12:35
说明:这里是使用eclipse来编写SSH,初次整理,请多关照!
具体整合步骤如下:
1.添加相对应的jar包(36个jar包)
2.添加hibernate配置文件 hibernate.cfg.xml
3.添加spring配置文件applicationContex.xml(如不想修改配置,请将文件放置WEB-INF目录下)
4.配置applicationContex.xml:
4.1 配置DataSource
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="username" value="root"></property>//用户名
<property name="password" value="0000"></property>//密码
<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>//驱动
<property name="url" value="jdbc:mysql:///test"></property>//url 其中test为数据库名
</bean>
4.2 配置sessionFactory
<bean id="sessionFactory"
class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="configLocation" value="classpath:hibernate.cfg.xml"></property>
<property name="dataSource" ref="dataSource"></property>
</bean>
4.3配置hibernateTemplate
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate5.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
5.创建bean类(相当于数据库中的表),定义对应属性(相当于表中的字段),生成spring映射文件。
在hibernate.cfg.xml中添加mapping 即:<mapping resource="org/mc/bean/BeanTest.hbm.xml"/>
6.创建Struts配置文件.xml文件 配置如下
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
/*
*具体内容
*/
</struts>
7.配置web.xml文件
7.1 Struts核心过滤器
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
7.2 spring监听
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
8.创建action类
9.在applicationContext.xml中配置bean来管理action类
10.配置Struts.xml 其中class引用applicatxionContext.xml中相对应的bean的id
11.在applicationContext.xml中添加相应的bean来管理对应的类。例如dao,service,action等。为这些类的有set方法的属性注入值。
- SSH spring+struts2+hibernate整合步骤
- Struts2, spring,hibernate 整合步骤
- struts2+spring+hibernate整合步骤
- Struts2+Hibernate+Spring整合步骤
- Struts2+Hibernate+Spring整合步骤
- Spring整合struts2+hibernate步骤
- ssh 整合 (spring + Struts2 + hibernate)
- ssh(Spring struts2 hibernate)整合
- SSH整合:Struts2+Spring+Hibernate
- 【SSH】Hibernate+Struts2+Spring整合
- spring+struts2+hibernate整合(ssh)
- ssh-ssh整合(Struts2+Spring+Hibernate)
- Spring、Struts2+Spring+Hibernate整合步骤
- SSH框架整合(Spring整合Struts2,和Spring整合Hibernate)
- 张英泽 struts2+spring+hibernate整合步骤
- struts2、hibernate、spring的整合步骤
- java Struts2,Spring,Hibernate的整合步骤
- struts2+spring+hibernate整合步骤《开源》
- 关于PLSQL配置了正确的Oracle客户端但是不能识别tnsnames.ora问题
- hashmap 与hashtable区别(学习工厂模式笔记)
- mysq使用问题记录
- caffe运行mnist出现-bash: ./examples/mnist/train_lenet.sh: usr/bin/env: bad interpreter: No such file问题解决
- 指针部分知识
- SSH spring+struts2+hibernate整合步骤
- 【OpenCV入门教程之一】 安装OpenCV:OpenCV 3.0、OpenCV 2.4.8、OpenCV 2.4.9 +VS 开发环境配置
- gcc/g++编译优化
- 搞定JAVA消息队列,看我用了几步
- 安卓开发的两种语言比较——Java & Kotlin
- unity 选择不同的枚举在面板上显示不同的属性
- MySQL 不能添加外键:Cannot add foreign key constraint错误
- 带你深入理解STL之Set和Map
- 【银行】2015农行软开 笔试+面试 小记