SSH框架笔记01_SSH整合的两种方式
1. 框架回顾

2. 创建项目,引入jar包
2.1 Struts2的jar包
- 基础包:
..\struts2\struts-2.3.24-apps\struts-2.3.24\apps\struts2-blank\WEB-INF\lib\*.jar
| asm-3.3.jar |
|---|
| asm-commons-3.3.jar |
| asm-tree-3.3.jar |
| commons-fileupload-1.3.1.jar |
| commons-io-2.2.jar |
| commons-lang3-3.2.jar |
| freemarker-2.3.22.jar |
| javassist-3.11.0.GA.jar |
| log4j-api-2.2.jar |
| log4j-core-2.2.jar |
| ognl-3.0.6.jar |
| struts2-core-2.3.24.jar |
| xwork-core-2.3.24.jar |
- 其他
..\struts2\struts-2.3.24\lib
| Struts2的注解开发包 | struts2-convention-plugin-2.3.24.jar |
|---|---|
| Struts2的整合AJAX的开发包 | struts2-json-plugin-2.3.24.jar |
| Struts2的整合Spring的开发包 | struts2-spring-plugin-2.3.24.jar |
2.2 Hibernate的jar包
- 必须的包:
..\hibernate-release-5.0.7.Final\lib\required
| antlr-2.7.7.jar |
|---|
| dom4j-1.6.1.jar |
| geronimo-jta_1.1_spec-1.1.1.jar |
| hibernate-commons-annotations-5.0.1.Final.jar |
| hibernate-core-5.0.7.Final.jar |
| hibernate-jpa-2.1-api-1.0.0.Final.jar |
| jandex-2.0.0.Final.jar |
| javassist-3.18.1-GA.jar |
| jboss-logging-3.3.0.Final.jar |
- MySQL驱动包:
mysql-connector-java-5.0.4-bin.jar - 日志包:
| log4j-1.2.16.jar |
|---|
| slf4j-api-1.6.1.jar |
| slf4j-log4j12-1.7.2.jar |
- 使用C3P0连接池:
..\hibernate-release-5.0.7.Final\lib\optional\c3p0\*.jar
| c3p0-0.9.2.1.jar |
|---|
| hibernate-c3p0-5.0.7.Final.jar |
| mchange-commons-java-0.2.3.4.jar |
- 注意:Struts2和Hibernate都引入了一个相同的jar包(javassist包)。删除一个。
2.3 Spring的jar包
- IOC的开发
| ..\spring-framework-4.2.4.RELEASE-dist\spring-framework-4.2.4.RELEASE\libs | spring-beans-4.2.4.RELEASE.jar |
|---|---|
| ..\spring-framework-4.2.4.RELEASE-dist\spring-framework-4.2.4.RELEASE\libs | spring-context-4.2.4.RELEASE.jar |
| ..\spring-framework-4.2.4.RELEASE-dist\spring-framework-4.2.4.RELEASE\libs | spring-core-4.2.4.RELEASE.jar |
| ..\spring-framework-4.2.4.RELEASE-dist\spring-framework-4.2.4.RELEASE\libs | spring-expression-4.2.4.RELEASE.jar |
| ..\spring相关依赖包\spring-framework-3.0.2.RELEASE-dependencies\org.apache.log4j\com.springsource.org.apache.log4j\1.2.15 | com.springsource.org.apache.log4j-1.2.15.jar |
| ..\spring相关依赖包\spring-framework-3.0.2.RELEASE-dependencies\org.apache.commons\com.springsource.org.apache.commons.logging\1.1.1 | com.springsource.org.apache.commons.logging-1.1.1.jar |
- AOP的开发
| ..\spring相关依赖包\spring-framework-3.0.2.RELEASE-dependencies\org.aopalliance\com.springsource.org.aopalliance\1.0.0 | com.springsource.org.aopalliance-1.0.0.jar |
|---|---|
| ..\spring相关依赖包\spring-framework-3.0.2.RELEASE-dependencies\org.aspectj\com.springsource.org.aspectj.weaver\1.6.8.RELEASE | com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar |
| ..\spring-framework-4.2.4.RELEASE-dist\spring-framework-4.2.4.RELEASE\libs | spring-aop-4.2.4.RELEASE.jar |
| ..\spring-framework-4.2.4.RELEASE-dist\spring-framework-4.2.4.RELEASE\libs | spring-aspects-4.2.4.RELEASE.jar |
- JDBC模板的开发
| ..\spring-framework-4.2.4.RELEASE-dist\spring-framework-4.2.4.RELEASE\libs | spring-jdbc-4.2.4.RELEASE.jar |
|---|---|
| ..\spring-framework-4.2.4.RELEASE-dist\spring-framework-4.2.4.RELEASE\libs | spring-tx-4.2.4.RELEASE.jar |
事务管理:
..\spring-framework-4.2.4.RELEASE-dist\spring-framework-4.2.4.RELEASE\libs\spring-tx-4.2.4.RELEASE.jar整合web项目的开发
..\spring-framework-4.2.4.RELEASE-dist\spring-framework-4.2.4.RELEASE\libs\spring-web-4.2.4.RELEASE.jar整合单元测试的开发
..\spring-framework-4.2.4.RELEASE-dist\spring-framework-4.2.4.RELEASE\libs\spring-test-4.2.4.RELEASE.jar整合Hibernate的开发
..\spring-framework-4.2.4.RELEASE-dist\spring-framework-4.2.4.RELEASE\libs\spring-orm-4.2.4.RELEASE.jar
3. 引入配置文件
3.1 Struts2配置的文件
- web.xml
<!-- 配置Struts2的核心过滤器 -->
<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>
- 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>
<!-- 配置Struts2的常量 -->
<constant name="struts.action.extension" value="action"/>
</struts>
3.2 Hibernate的配置文件
- hibernate.cfg.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- 连接数据库的基本参数 -->
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql:///ssh1</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">2626</property>
<!-- 配置Hibernate的方言 -->
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- 可选配置================ -->
<!-- 打印SQL -->
<property name="hibernate.show_sql">true</property>
<!-- 格式化SQL -->
<property name="hibernate.format_sql">true</property>
<!-- 自动创建表 -->
<property name="hibernate.hbm2ddl.auto">update</property>
<!-- 配置C3P0连接池 -->
<property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<!--在连接池中可用的数据库连接的最少数目 -->
<property name="c3p0.min_size">5</property>
<!--在连接池中所有数据库连接的最大数目 -->
<property name="c3p0.max_size">20</property>
<!--设定数据库连接的过期时间,以秒为单位,
如果连接池中的某个数据库连接处于空闲状态的时间超过了timeout时间,就会从连接池中清除 -->
<property name="c3p0.timeout">120</property>
<!--每3000秒检查所有连接池中的空闲连接 以秒为单位-->
<property name="c3p0.idle_test_period">3000</property>
<!-- 引入映射 -->
</session-factory>
</hibernate-configuration>
删除那个与线程绑定的session
映射文件
3.3 Spring的配置文件
- web.xml
<!-- Spring的核心监听器 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- 加载Spring的配置文件的路径的,默认加载的/WEB-INF/applicationContext.xml -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
- applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
</beans>
- 日志记录:
log4j.properties
### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.err
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
### direct messages to file mylog.log ###
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.File=c\:mylog.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
### set log levels - for more verbose logging change 'info' to 'debug' ###
# error warn info debug trace
log4j.rootLogger= info, stdout
4. 创建包结构

5. 创建相关类,引入页面

6. Spring整合Struts2
6.1 Spring整合Struts2方式一:Action由Struts2自身创建
- 编写
Action:CustomerAction
package com.itzhouq.web.action;
import com.itzhouq.domain.Customer;
/**
* 客户管理的Action类
*/
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
public class CustomerAction extends ActionSupport implements ModelDriven<Customer> {
// 模型驱动使用的对象
private Customer customer = new Customer();
@Override
public Customer getModel() {
return customer;
}
/**
* 保存客户的方法:save
*/
public String save() {
System.out.println("Action的save方法执行了。。。。");
return NONE;
}
}
- 配置
Action:在struts.xml中配置
<!-- 配置Action -->
<package name="ssh1" extends="struts-default" namespace="/">
<action name="customer_*" class="com.itzhouq.web.action.CustomerAction" method="{1}">
</action>
</package>
- 在
Action中引入Service----传统方式
// 如果web层没有使用Struts2,获取业务层的类就必须如下进行编写:
WebApplicationContext applicationContext = WebApplicationContextUtils
.getWebApplicationContext(ServletActionContext.getServletContext());
CustomerService customerService = (CustomerService) applicationContext.getBean("customerService");
- 在
Action中引入Service----Spring和Struts2整合- 引入
Spring整合Struts2的jar包struts2-spring-plugin-2.3.24.jar
- 引入
- 在插件包中有如下配置
<!-- Make the Spring object factory the automatic default -->
<constant name="struts.objectFactory" value="spring" />
- 开启一个常量:在Struts2中只有开启这个常量就会引发下面常量生效,在
Struts2核心包下default.properties

- 将
Service交给Spring管理,让Action按照名称自动注入Service。在Spring的配置文件中做如下配置。
<!-- 配置Service================ -->
<bean id="customerService" class="com.itzhouq.service.impl.CustomerServiceImpl">
</bean>
Action注入Servcie
package com.itzhouq.web.action;
import org.apache.struts2.ServletActionContext;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import com.itzhouq.domain.Customer;
import com.itzhouq.service.CustomerService;
/**
* 客户管理的Action类
*/
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
public class CustomerAction extends ActionSupport implements ModelDriven<Customer> {
// 模型驱动使用的对象
private Customer customer = new Customer();
@Override
public Customer getModel() {
return customer;
}
// 注入customerService
private CustomerService customerService;
public void setCustomerService(CustomerService customerService) {
this.customerService = customerService;
}
/**
* 保存客户的方法:save
*/
public String save() {
System.out.println("Action的save方法执行了。。。。");
// 如果web层没有使用Struts2,获取业务层的类就必须如下进行编写:
// WebApplicationContext applicationContext = WebApplicationContextUtils
// .getWebApplicationContext(ServletActionContext.getServletContext());
// CustomerService customerService = (CustomerService) applicationContext.getBean("customerService");
customerService.save(customer);
return NONE;
}
}
6.2 Spring整合Struts2方式二:Action交给Spring管理【推荐】
引入
Spring整合Struts2的jar包struts2-spring-plugin-2.3.24.jar将
Action交给Spring管理,在Spring的配置文件中配置
<!-- 配置Action============= -->
<bean id="customerAction" class="com.itzhouq.web.action.CustomerAction" scope="prototype" >
<!-- 手动注入Service -->
<property name="customerService" ref="customerService"/>
</bean>
- 在
struts.xml中配置,class属性变为Spring中的id的值
<!-- 配置Action -->
<package name="ssh1" extends="struts-default" namespace="/">
<action name="customer_*" class="customerAction" method="{1}">
</action>
</package>
- 注意:
- 需要配置
Action为多例的 - 需要手动注入
Service
- 需要配置
7. Service调用Dao
- 将
Dao交给Spring管理:applicationContext.xml中添加配置
<!-- 配置Dao -->
<bean id="customerDao" class="com.itzhouq.dao.impl.CustomerDaoImpl">
</bean>
- 在
Service层注入Dao:CustomerServiceImpl中注入
public class CustomerServiceImpl implements CustomerService {
// 注入Dao
private CustomerDao customerDao;
public void setCustomerDao(CustomerDao customerDao) {
this.customerDao = customerDao;
}
@Override
public void save(Customer customer) {
System.out.println("Service中的save方法执行了。。。。。");
}
}
- 注入配置
<!-- 配置Service================ -->
<bean id="customerService" class="com.itzhouq.service.impl.CustomerServiceImpl">
<property name="customerDao" ref="customerDao"></property>
</bean>
8. Spring整合Hibernate
8.1 创建数据库和表
Create database ssh1;
Use ssh1;
CREATE TABLE `cst_customer` (
`cust_id` bigint(32) NOT NULL AUTO_INCREMENT COMMENT '客户编号(主键)',
`cust_name` varchar(32) NOT NULL COMMENT '客户名称(公司名称)',
`cust_source` varchar(32) DEFAULT NULL COMMENT '客户信息来源',
`cust_industry` varchar(32) DEFAULT NULL COMMENT '客户所属行业',
`cust_level` varchar(32) DEFAULT NULL COMMENT '客户级别',
`cust_phone` varchar(64) DEFAULT NULL COMMENT '固定电话',
`cust_mobile` varchar(16) DEFAULT NULL COMMENT '移动电话',
PRIMARY KEY (`cust_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
8.2 编写实体和映射
public final class Customer {
private Long cust_id;
private String cust_name;
private String cust_source;
private String cust_industry;
private String cust_level;
private String cust_phone;
private String cust_mobile;
//set/get方法
}
com/itzhouq/domain/Customer.hbm.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<!-- 建立类与表的映射 -->
<class name="com.itzhouq.domain.Customer" table="cst_customer">
<!-- 建立类中的属性与表中的主键对应 -->
<id name="cust_id" column="cust_id" >
<!-- 主键生成策略 -->
<generator class="native"/>
</id>
<!-- 建立类中的普通的属性和表的字段的对应 -->
<property name="cust_name" column="cust_name" />
<property name="cust_source" column="cust_source"/>
<property name="cust_industry" column="cust_industry"/>
<property name="cust_level" column="cust_level"/>
<property name="cust_phone" column="cust_phone"/>
<property name="cust_mobile" column="cust_mobile"/>
</class>
</hibernate-mapping>
- 在
hibernate.cfg.xml中引入映射文件
<!-- 引入映射 -->
<mapping resource="com/itzhouq/domain/Customer.hbm.xml"/>
8.3 Spring和Hibernate整合
- 在
Spring的配置文件application.xml中引入Hibernate的配置信息
<!-- Spring整合Hibernate -->
<!-- 引入Hibernate的配置的信息=============== -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<!-- 引入hibernate的配置文件 -->
<property name="configLocation" value="classpath:hibernate.cfg.xml"/>
</bean>
- 在Spring和Hibernate整合后,Spring提供了一个Hibernate的模板类简化Hibernate开发
- 改写
DAO继承HibernateDaoSupport
public class CustomerDaoImpl extends HibernateDaoSupport implements CustomerDao {
@Override
public void save(Customer customer) {
System.out.println("Dao中的save方法执行了。。。。");
}
}
- 配置的时候在
DAO中直接注入SessionFactory:注入SessionFactory就会创建Hibernate模板。
<!-- 配置Dao -->
<bean id="customerDao" class="com.itzhouq.dao.impl.CustomerDaoImpl">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
- 在
DAO中使用Hibernate的模板完成保存操作
package com.itzhouq.dao.impl;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
/**
* 客户管理的dao层的实现类
* @author itzhouq
*
*/
import com.itzhouq.dao.CustomerDao;
import com.itzhouq.domain.Customer;
public class CustomerDaoImpl extends HibernateDaoSupport implements CustomerDao {
@Override
public void save(Customer customer) {
System.out.println("Dao中的save方法执行了。。。。");
this.getHibernateTemplate().save(customer);
}
}
8.4 配置Spring的事务管理器
- 配置事务管理器,开启注解事务
<!-- 配置事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!-- 开启注解事务 -->
<tx:annotation-driven transaction-manager="transactionManager"/>
- 在业务层使用注解
@Transactional
public class CustomerDaoImpl extends HibernateDaoSupport implements CustomerDao {
9. SSH整合方式二:将Hibernate的配置交给Spring管理
9.1 复制一个项目
- 复制一个项目,并修改
Properties ---- Web Project Settings-----Comtext Root的名称
9.2 将Hibernate的相关属性的配置转移到Spring
- 数据库连接的配置:使用
jdbc.properties
jdbc.driverClass=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql:///ssh1
jdbc.username=root
jdbc.password=2626
- 在
Spring中引入
<!-- 引入外部属性文件=============================== -->
<context:property-placeholder location="classpath:jdbc.properties"/>
- C3P0连接池:在
Spring中
<!-- 配置C3P0连接池=============================== -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${jdbc.driverClass}"/>
<property name="jdbcUrl" value="${jdbc.url}"/>
<property name="user" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</bean>
- 整合Hibernate的配置
<!-- Spring整合Hibernate -->
<!-- 引入Hibernate的配置的信息=============== -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<!-- 注入连接池 -->
<property name="dataSource" ref="dataSource"/>
<!-- 配置Hibernate的相关属性 -->
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
<!-- 设置映射文件 -->
<property name="mappingResources">
<list>
<value>com/itzhouq/domain/Customer.hbm.xml</value>
</list>
</property>
</bean>
9.3 Spring的配置文件最终版
删除
Hibernate的配置文件最终
Spring的配置文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
<!-- 引入外部属性文件=============================== -->
<context:property-placeholder location="classpath:jdbc.properties"/>
<!-- 配置C3P0连接池=============================== -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${jdbc.driverClass}"/>
<property name="jdbcUrl" value="${jdbc.url}"/>
<property name="user" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</bean>
<!-- Spring整合Hibernate -->
<!-- 引入Hibernate的配置的信息=============== -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<!-- 注入连接池 -->
<property name="dataSource" ref="dataSource"/>
<!-- 配置Hibernate的相关属性 -->
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
<!-- 设置映射文件 -->
<property name="mappingResources">
<list>
<value>com/itzhouq/domain/Customer.hbm.xml</value>
</list>
</property>
</bean>
<!-- 配置Dao -->
<bean id="customerDao" class="com.itzhouq.dao.impl.CustomerDaoImpl">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!-- 配置Action============= -->
<bean id="customerAction" class="com.itzhouq.web.action.CustomerAction" scope="prototype" >
<!-- 手动注入Service -->
<property name="customerService" ref="customerService"/>
</bean>
<!-- 配置Service================ -->
<bean id="customerService" class="com.itzhouq.service.impl.CustomerServiceImpl">
<property name="customerDao" ref="customerDao"></property>
</bean>
<!-- 配置事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!-- 开启注解事务 -->
<tx:annotation-driven transaction-manager="transactionManager"/>
</beans>
SSH框架笔记01_SSH整合的两种方式的更多相关文章
- SQLite3学习笔记----创建数据库的两种方式
今天研究学习SQLite,刚开始创建数据库,就遇到了一个坑,是自己粗心了,特记录一下. 实验环境: OS:Ubuntu18.04 创建数据库名称:test.db 实验步骤: 1.检查是否已经安装了SQ ...
- 5.Maven和Eclipse整合(两种方式进行插件的安装),Maven相关设置,Eclipse下创建Maven项目
1 第一种方式是:在连网的情况下.通过在helpàInstall下安装. 新的地址是:http://download.eclipse.org/technology/m2e/releases 2 ...
- [Java] SSH框架笔记_S2SH整合步骤
http://tech.ddvip.com/2009-09/1253783051134206.html http://www.blogjava.net/liu0909/archive/2009/07/ ...
- struts2与velocity的整合有两种方式
1.以struts2为主.struts2内置了对velocity的支持,只要在<result name="success"?type="velocity" ...
- python 学习笔记(二)两种方式实现第一个python程序
在交互模式下: 如果要让Python打印出指定的文字,可以用print语句,然后把希望打印的文字用单引号或者双引号括起来,但不能混用单引号和双引号: >>> print 'hello ...
- Struts2实现ajax的两种方式
基于Struts2框架下实现Ajax有两种方式,第一种是原声的方式,另外一种是struts2自带的一个插件. js部分调用方式是一样的: JS代码: function testAjax() { var ...
- TP实例化模型的两种方式 M() D()
TP框架中实例化模型的两种方式 #如果使用自己自定义的函数,那么就用D $mode=D('model'); #如果使用是系统自带的函数,那么就是用M $model=M('model');
- SSH框架的基本整合
SSH框架的基本整合 AOP注解方式 编写切面类(包括通知和切入点) 开启自己主动代理 JDBC模板技术 Spring提供模板技术,数据库的操作 以后编写DAO层,都能够继承JdbcDaoSuppor ...
- Maven环境下搭建SSH框架之Spring整合Hibernate
© 版权声明:本文为博主原创文章,转载请注明出处 1.搭建环境 Spring:4.3.8.RELEASE Hibernate:5.1.7.Final MySQL:5.7.17 注意:其他版本在某些特性 ...
随机推荐
- PostgreSQL中的Object Identifier(oid)数据类型
PostgreSQL在内部使用对象标识符(OID)作为各种系统表的主键.OID不会添加到用户创建的表中,除非在创建表时指定了WITH OIDS,或者启用了default_with_oids配置变量.类 ...
- Python numpy 中常用的数据运算
Numpy 精通面向数组编程和思维方式是成为Python科学计算大牛的一大关键步骤.——<利用Python进行数据分析> Numpy(Numerical Python)是Python科学计 ...
- 解决Electron安装包下载慢的问题
问题描述 在运行官网示例的过程中,一个安装包(electron-v5.0.8-darwin-x64.zip)下载特别慢,基本下载不下来.更改npm的安装源到taobao的镜像,也没有效果. 解决方案 ...
- C# redis客户端帮助类
需要在NuGet里面引用ServiceStack.Redis using ServiceStack.Redis; using ServiceStack.Redis.Generic; using Sys ...
- 人工智能新编程语言-Gen
MIT 的一个研究小组正努力让初学者更容易入门人工智能,同时也帮助专家进一步推进这个领域的发展. 在 PLDI 大会(Programming Language Design and Implement ...
- Linux安全学习
安全游戏说明 游戏形式帮助初学者学习和实践网络安全,主要是Linux shell命令的练习. https://overthewire.org/wargames/ 二进制 灰帽黑客进阶秘籍之一--lin ...
- 高级UI-画笔Paint
在UI这一块,谈到自定义,就离不开画笔和画布的使用话题,在自定义控件的时候,为了做出炫酷的效果,我们往往会使用画笔和画布,那么这里我们就先来看看画笔的使用吧 简单使用例子 自定义一个View publ ...
- redis主从分节
概述 在现有企业中80%公司大部分使用的是redis单机服务,在实际的场景当中单一节点的redis容易面临风险. 面临问题 机器故障.我们部署到一台 Redis 服务器,当发生机器故障时,需要迁移到另 ...
- 【面试】C++类中的相关函数【构造,拷贝构造,析构,友元】
构造函数:值的初始化,可带参数,无返回值,可重载,可存在多个 析构函数:释放对象内存空间,无参数,无返回值,不可重载,只能存在一个 拷贝构造函数:拷贝对象,其形参必须是引用 1.空类会默认添加哪些东西 ...
- JAVA day1 基础知识
一.windows命令 dir:查看文件 cd:打开文件 二.java的编译和运行 编译: javac 源文件名 一个类编译后会对应一个.class文件 运行: java 类名 三.类 一个源文件内可 ...