首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

如何搭建SSH框架,myeclipse搭建SSH框架详解

新建一个Maven web项目:ssh

2

在maven配置中加入spring依赖支持。

org.springframework

spring-webmvc

4.3.7.RELEASE

org.springframework

spring-jdbc

4.3.7.RELEASE

org.springframework

spring-aspects

4.3.7.RELEASE

org.springframework spring-orm 4.3.7.RELEASE

3

在web.xml文件中配置spring的listener:

xmlns="http://java.sun.com/xml/ns/javaee"

xsi:schemaLocation="http://java.sun.com/xml/ns/javaee

http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"

id="WebApp_ID" version="3.0">

contextConfigLocation

classpath:applicationContext.xml

4

在resources资源目录中新建一个applicationContext.xml文件。

5

加入hibernate依赖包:

org.hibernate

hibernate-core

4.2.4.Final

mysql

mysql-connector-java

5.0.2

6

true

true

thread

7

建立持久化类和其对应的.hbm.xml文件。

"-//Hibernate/Hibernate Mapping DTD 3.0//EN"

"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

table="ssh_department">

8

hibernate和spring进行整合,在maven中加入c3p0依赖包。

c3p0

c3p0

0.9.1

9

在resources资源文件中新建一个dbconfig.properties文件:

jdbc.jdbcUrl=jdbc:mysql://localhost:3306/sshjdbc.driverClass=com.mysql.jdbc.Driverjdbc.user=rootjdbc.password=root

10

hibernate和spring进行整合,配置数据源。

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:p="http://www.springframework.org/schema/p"

xmlns:context="http://www.springframework.org/schema/context"

xmlns:aop="http://www.springframework.org/schema/aop"

xmlns:tx="http://www.springframework.org/schema/tx"

xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd

http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd

http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd

http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">

11

hibernate和spring进行整合配置SessionFactory。

12

hibernate和spring进行整合,配置声明式事务。

13

启动项目,会看到生成的数据表。

14

在maven配置文件中加入Struts2依赖包:

struts2-core

2.3.15

struts2-spring-plugin

2.3.15

15

在web.xml文件中配置Struts2的Filter:

struts2

struts2

/*

16

加入struts2的配置文件:

"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"

"http://struts.apache.org/dtds/struts-2.3.dtd">

17

整合Spring与Struts2。

在maven配置文件中加入Struts2的Spring插件依赖包:

struts2-spring-plugin

2.3.15

18

在Spring的配置文件中正常配置Action,注意Action的scope为prototype。

19

在Struts2的配置文件中配置Action时,class属性执行该Action在IOC中的id。

"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"

"http://struts.apache.org/dtds/struts-2.3.dtd">

  • 发表于:
  • 原文链接http://kuaibao.qq.com/s/20180203A14GA300?refer=cp_1026
  • 腾讯「腾讯云开发者社区」是腾讯内容开放平台帐号(企鹅号)传播渠道之一,根据《腾讯内容开放平台服务协议》转载发布内容。
  • 如有侵权,请联系 cloudcommunity@tencent.com 删除。

扫码

添加站长 进交流群

领取专属 10元无门槛券

私享最新 技术干货

扫码加入开发者社群
领券