UTF-8
2.5.10
4.3.8.RELEASE
5.1.7.Final
junit
junit
4.12
test
org.springframework
spring-core
${spring.version}
org.springframework
spring-web
${spring.version}
org.springframework
spring-orm
${spring.version}
org.apache.struts
struts2-core
${struts.version}
org.apache.struts
struts2-spring-plugin
${struts.version}
org.hibernate
hibernate-core
${hibernate.version}
mysql
mysql-connector-java
5.1.42
com.mchange
c3p0
0.9.5
org.aspectj
aspectjweaver
1.8.10
org.slf4j
slf4j-log4j12
1.7.25
javax
javaee-api
7.0
maven_ssh
org.apache.maven.plugins
maven-surefire-plugin
2.19.1
true
struts2
org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
struts2
/*
applicationContext.xml
contextConfigLocation
classpath:applicationContext.xml
org.springframework.web.context.ContextLoaderListener
true
true
update
org.hibernate.dialect.MySQL5InnoDBDialect
CustomerAction.java
public class CustomerAction extends ActionSupport {
}
applicationContext.xml
struts.xml
applicationContext.xml
db.properties
jdbc.driverClass=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/javaweb
jdbc.username=root
jdbc.password=T471912619
applicationContext.xml
Customer.java
public class Customer {
private String custId;
private String custName;
private String address;
public String getCustId() {
return custId;
}
public void setCustId(String custId) {
this.custId = custId;
}
public String getCustName() {
return custName;
}
public void setCustName(String custName) {
this.custName = custName;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
}
Customer.hbm.xml
hibernate.cfg.xml
public class CustomerAction extends ActionSupport {
private CustomerService customerService;
private String custId;
public void setCustomerService(CustomerService customerService) {
this.customerService = customerService;
}
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;
}
}
public interface CustomerService {
Customer findOne(String custId);
}
public class CustomerServiceImpl implements CustomerService {
private CustomerDao customerDao;
public void setCustomerDao(CustomerDao customerDao) {
this.customerDao = customerDao;
}
@Override
public Customer findOne(String custId) {
return customerDao.findOne(custId);
}
}
public interface CustomerDao {
Customer findOne(String custId);
}
public class CustomerDaoImpl extends HibernateDaoSupport implements CustomerDao {
public Customer findOne(String custId) {
return this.getHibernateTemplate().get(Customer.class,custId);
}
}
applicationContext
/index.jsp
findOne
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
Insert title here
访问http://localhost:8080/maven_ssh/customerAction_findOne.action?custId=1
成功!!!!!!!