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

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

一,引jar包

Hebirnate
cn.happy
1.0-SNAPSHOT
4.0.0
sshAnno
war
sshAnno Maven Webapp
http://maven.apache.org
junit
junit
3.8.1
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
src/main/java
**/*.xml

二,搭建项目

2.1 entity包下Dept类

public class Dept {    private Integer deptno;    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.1.1 entity包下Dept.hbm.xml

2.2   DAO包下IDeptDao接口

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

2.2.1 DAO包下DeptDaoImpl

public class DeptAction implements Action {    private Dept dept;    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;    }    public String execute() throws Exception {        service.addDept(dept);        return SUCCESS;    }}

2.3 Service包下IDeptService接口

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

2.3.1 Service包下DeptServiceImpl

public class DeptServiceImpl implements IDeptService{    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

public class DeptAction implements Action {    private Dept dept;    IDeptService service;    public String execute() throws Exception {        service.addDept(dept);        return SUCCESS;    }    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;    }}

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  resources下struts.xml 

/add.jsp

2.8 千万别忘了配置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/8508790.html

你可能感兴趣的文章
gnome桌面无法使用笔记本的触摸板
查看>>
默认npm太慢,换用淘宝npm镜像
查看>>
设置谷歌浏览器为默认浏览器
查看>>
最大值
查看>>
html (超文本标记语言)
查看>>
springmvc与Ajax交互
查看>>
图片 滚动切换效果(三)
查看>>
response.setHeader()的用法
查看>>
日期格式化
查看>>
java基础入门-建立能够多client链接的ServerSocket
查看>>
刨根问底Objective-C Runtime(4)- 成员变量与属性
查看>>
hdu4734 数位dp + 小技巧
查看>>
mouseover和mouseenter的区别
查看>>
索引字段的宽度降下来?
查看>>
js 唤起APP
查看>>
专车降价滴滴快车使命终结?
查看>>
Java for LeetCode 098 Validate Binary Search Tree
查看>>
Java for LeetCode 108 Convert Sorted Array to Binary Search Tree
查看>>
改变UITextField placeHolder 字体 颜色
查看>>
关于asp下gridview的一些问题
查看>>