博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ssh框架整合之注解版
阅读量:4705 次
发布时间:2019-06-10

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

一,引jar包

junit
junit
4.3
test
org.springframework
spring-context
4.2.0.RELEASE
org.aspectj
aspectjweaver
1.8.7
org.springframework
spring-web
4.1.8.RELEASE
javaee
javaee-api
5
javax.servlet
jstl
1.2
runtime
org.springframework
spring-tx
4.2.5.RELEASE
com.mchange
c3p0
0.9.5.2
javax.transaction
jta
1.1
org.hibernate
hibernate-core
5.0.6.Final
org.springframework
spring-orm
4.2.2.RELEASE
com.oracle
ojdbc6
11.2.0.1.0
org.apache.struts
struts2-core
2.3.4.1
org.springframework
spring-jdbc
4.3.13.RELEASE
org.apache.struts.xwork
xwork-core
2.3.4.1
org.apache.struts
struts2-spring-plugin
2.3.4.1
org.apache.struts
struts2-convention-plugin
2.3.4.1
org.springframework
spring-jdbc
4.3.13.RELEASE

二, 项目架构

2.1 entity包下Dept

@Entity@Table(name = "Dept")public class Dept {    @Id    @GeneratedValue    private Integer deptno;    @Column    private String deptname;    public Integer getDeptno() {        return deptno;    }    public void setDeptno(Integer deptno) {        this.deptno = deptno;    }    public String getDeptname() {        return deptname;    }    public void setDeptname(String deptname) {        this.deptname = deptname;    }}

2.2 Dao包下IDeptDao

public interface IDeptDao {    public int addDept(Dept dept);}

2.2.2 Dao包下DeptDaoImpl 

@Repository("deptDAO")public class DeptDaoImpl implements IDeptDao {    @Resource(name ="sessionFactory")    SessionFactory sessionFactory;    public SessionFactory getSessionFactory() {        return sessionFactory;    }    public void setSessionFactory(SessionFactory sessionFactory) {        this.sessionFactory = sessionFactory;    }    public int addDept(Dept dept) {        Session session=sessionFactory.getCurrentSession();        Serializable count=session.save(dept);        return (Integer) count;    }}

2.3 Service包下IDeptService

public interface IDeptService {    public int addDept(Dept dept);}

2.3.2 Service包下DeptServicImpl

*/@Service("deptService")public class DeptServiceImpl implements IDeptService{     @Resource(name = "deptDAO")    IDeptDao dao;    public IDeptDao getDao() {        return dao;    }    public void setDao(IDeptDao dao) {        this.dao = dao;    }    @Transactional    public int addDept(Dept dept) {        return dao.addDept(dept);    }}

2.4 action包下DeptAction

@Controller("deptAction")@ParentPackage("struts-default")@Namespace("/")@Scope("prototype")public class DeptAction implements Action {    private Dept dept;    @Resource(name = "deptService")    IDeptService service;    public Dept getDept() {        return dept;    }    public void setDept(Dept dept) {        this.dept = dept;    }    public IDeptService getService() {        return service;    }    public void setService(IDeptService service) {        this.service = service;    }@org.apache.struts2.convention.annotation.Action(value = "/add",results = {@Result(name ="success",location = "/add.jsp")})    public String execute() throws Exception {        service.addDept(dept);        return SUCCESS;    }}

2.5 resources包下applicationContext.xml

org.hibernate.dialect.Oracle10gDialect
true
true
org.springframework.orm.hibernate5.SpringSessionContext

2.6 resources包下jdbc.properties

jdbc.jdbcUrl=jdbc:oracle:thin:@localhost:1521:orcljdbc.driverClass=oracle.jdbc.driver.OracleDriverjdbc.username=zyxjdbc.password=zyx

2.7配置web.xml

Archetype Created Web Application
contextConfigLocation
classpath:applicationContext.xml
struts1
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
struts1
/*
org.springframework.web.context.ContextLoaderListener

三,配置Web页面

3.1 index.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>添加部门
部门名称:

转载于:https://www.cnblogs.com/spghs/p/8508919.html

你可能感兴趣的文章
Java parseInt()方法
查看>>
yahoo的30条优化规则
查看>>
[CCF2015.09]题解
查看>>
[NYIST15]括号匹配(二)(区间dp)
查看>>
json_value.cpp : fatal error C1083: 无法打开编译器生成的文件:No such file or directory
查看>>
洛谷 P1101 单词方阵
查看>>
Swift DispatchQueue
查看>>
C#和JAVA 访问修饰符
查看>>
小甲鱼OD学习第1讲
查看>>
HDU-1085 Holding Bin-Laden Captive-母函数
查看>>
php提示undefined index的几种解决方法
查看>>
LRJ
查看>>
Struts2环境搭建
查看>>
Linux: Check version info
查看>>
stl学习之测试stlen,cout等的运行速度
查看>>
魔戒三曲,黑暗散去;人皇加冕,光明归来
查看>>
Error和Exception
查看>>
Python和Singleton (单件)模式[转载]
查看>>
httpclient设置proxy与proxyselector
查看>>
IT常用单词
查看>>