博客
关于我
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 CPU使用率过高的一次处理经历
查看>>
Multisim中555定时器使用技巧
查看>>
MySQL CRUD 数据表基础操作实战
查看>>
multisim变压器反馈式_穿过隔离栅供电:认识隔离式直流/ 直流偏置电源
查看>>
mysql csv import meets charset
查看>>
multivariate_normal TypeError: ufunc ‘add‘ output (typecode ‘O‘) could not be coerced to provided……
查看>>
MySQL DBA 数据库优化策略
查看>>
multi_index_container
查看>>
mutiplemap 总结
查看>>
MySQL Error Handling in Stored Procedures---转载
查看>>
MVC 区域功能
查看>>
MySQL FEDERATED 提示
查看>>
mysql generic安装_MySQL 5.6 Generic Binary安装与配置_MySQL
查看>>
Mysql group by
查看>>
MySQL I 有福啦,窗口函数大大提高了取数的效率!
查看>>
mysql id自动增长 初始值 Mysql重置auto_increment初始值
查看>>
MySQL in 太多过慢的 3 种解决方案
查看>>
Mysql Innodb 锁机制
查看>>
MySQL InnoDB中意向锁的作用及原理探
查看>>
MySQL InnoDB事务隔离级别与锁机制深入解析
查看>>