首页 > 代码库 > 搭建一个SSH项目框架的步骤
搭建一个SSH项目框架的步骤
1、导入jar包(38个)
2、配置文件
applicationContext,xml (beans.xml)
(数据源、LocalSessionFactoryBean、事务管理器、事务通知、AOP切面、组件扫描、对注解提供支持)
Struts.xml
3,web.xml
Struts2过滤器
<filter>
<filter-name>action</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
Spring 的监听器contextConfigLocation
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:beans.xml</param-value>
</context-param>
<!--配置spring框架的上下文载入监听器-->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
数据源配置:
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="http://www.mamicode.com/${driverClass}"></property>
<property name="jdbcUrl" value="http://www.mamicode.com/${jdbcUrl}"></property>
<property name="user" value="http://www.mamicode.com/${user}"></property>
<property name="password" value="http://www.mamicode.com/${password}"></property>
<property name="initialPoolSize" value="http://www.mamicode.com/${initialPoolSize}"></property>
<property name="maxPoolSize" value="http://www.mamicode.com/${maxPoolSize}"></property>
<property name="minPoolSize" value="http://www.mamicode.com/${minPoolSize}"></property>
</bean>
Jdbc.properties
MySQL:
driverClass=com.mysql.jdbc.Driver
jdbcUrl=jdbc:mysql://localhost:3306/数据库名
user=root
password=root
initialPoolSize=30
maxPoolSize=50
minPoolSize=30
SqlServer:
jdbc.driverClassName=net.sourceforge.jtds.jdbc.Driver
jdbc.url=jdbc:jtds:sqlserver://localhost:1433/数据名
jdbc.username=sa
jdbc.password=abc123
initialPoolSize=30
maxPoolSize=50
minPoolSize=30
Oracle:
jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
jdbc.url=jdbc:orcale:thin://localhost:1521/数据库名
jdbc.username=wapcms
jdbc.password=wapcms
搭建一个SSH项目框架的步骤