博客
关于我
maven整合Struts2-Spring-Hibernate
阅读量:378 次
发布时间:2019-03-05

本文共 6255 字,大约阅读时间需要 20 分钟。

配置文件

pom.xml

4.0.0
com.sram
MavenAndSSH
0.0.1-SNAPSHOT
war
4.2.4.RELEASE
5.0.7.Final
2.3.24
org.springframework
spring-context
${spring.version}
org.springframework
spring-aspects
${spring.version}
org.springframework
spring-orm
${spring.version}
org.springframework
spring-test
${spring.version}
org.springframework
spring-web
${spring.version}
org.hibernate
hibernate-core
${hibernate.version}
org.apache.struts
struts2-core
${struts.version}
org.apache.struts
struts2-spring-plugin
${struts.version}
org.springframework
spring-context
org.springframework
spring-aspects
org.springframework
spring-orm
org.springframework
spring-test
org.springframework
spring-web
org.hibernate
hibernate-core
mysql
mysql-connector-java
5.1.6
runtime
c3p0
c3p0
0.9.1.2
org.apache.struts
struts2-core
org.apache.struts
struts2-spring-plugin
javax.servlet
servlet-api
2.5
provided
javax.servlet
jsp-api
2.0
provided
org.slf4j
slf4j-log4j12
1.7.2
junit
junit
4.9
test
javax.servlet
jstl
1.2
com.alibaba
fastjson
1.1.15
org.apache.commons
commons-lang3
3.4
org.apache.maven.plugins
maven-compiler-plugin
1.7
1.7
UTF-8

web.xml

MavenAndSSH
index.html
struts
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
struts
/*
org.springframework.web.context.ContextLoaderListener
contextConfigLocation
classpath:applicationContext.xml

struts.xml

/index.jsp

applicationContext.xml

hibernate.cfg.xml

org.hibernate.dialect.MySQL5Dialect
true
true
update

Customer.hbm.xml实体类的配置文件,通过配置方式

db.properties

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

代码

action中的代码

public class CustomerAction extends ActionSupport {	//action中因为在配置文件中注入了service层的对象,所以在这儿可以引用,但是需要天机set方法	private CustomerService customerService;	public void setCustomerService(CustomerService customerService) {		this.customerService = customerService;	}			//前台传入的请求参数保存到值栈中,,在这儿可以获取	private String custId;	public void setCustId(String custId) {		this.custId = custId;	}	//根据主键查询	public String findOne() throws Exception {		Customer customer = customerService.findOne(custId);		ActionContext.getContext().getValueStack().push(customer);		return SUCCESS;	}	}

service层的代码

public class CustomerServiceImpl implements CustomerService {	private CustomerDao customerDao;	public void setCustomerDao(CustomerDao customerDao) {		this.customerDao = customerDao;	}	public Customer findOne(String custId) {		return customerDao.findOne(custId);	}}

DAO层的代码

//继承HibernateDaoSupport public class CustomerDaoImpl extends HibernateDaoSupport implements CustomerDao {	public Customer findOne(String custId) {		return this.getHibernateTemplate().get(Customer.class, custId);	}	}

转载地址:http://lsrg.baihongyu.com/

你可能感兴趣的文章
mysql中的undo log、redo log 、binlog大致概要
查看>>
Mysql中的using
查看>>
MySQL中的关键字深入比较:UNION vs UNION ALL
查看>>
mysql中的四大运算符种类汇总20多项,用了三天三夜来整理的,还不赶快收藏
查看>>
mysql中的字段如何选择合适的数据类型呢?
查看>>
MySQL中的字符集陷阱:为何避免使用UTF-8
查看>>
mysql中的数据导入与导出
查看>>
MySQL中的时间函数
查看>>
mysql中的约束
查看>>
MySQL中的表是什么?
查看>>
mysql中穿件函数时候delimiter的用法
查看>>
Mysql中索引的分类、增删改查与存储引擎对应关系
查看>>
Mysql中索引的最左前缀原则图文剖析(全)
查看>>
MySql中给视图添加注释怎么添加_默认不支持_可以这样取巧---MySql工作笔记002
查看>>
Mysql中获取所有表名以及表名带时间字符串使用BetweenAnd筛选区间范围
查看>>
Mysql中视图的使用以及常见运算符的使用示例和优先级
查看>>
Mysql中触发器的使用示例
查看>>
Mysql中设置只允许指定ip能连接访问(可视化工具的方式)
查看>>
mysql中还有窗口函数?这是什么东西?
查看>>
mysql中间件
查看>>