Struts2+Spring3.1+Hibernate3.3的整个项目

经过一天的折腾,终于在MyEclipse2013下搭建出一个Struts2+Spring3.1+Hibernate3.3整合的项目,具体过程如下,仅供新手学习,大神勿喷

首先新建Web项目:

直接finish完成即可!

加入Spring支持:

弹出如下窗口:

此处将Spring配置文件的名称改为applicationContext-hibernate.xml用来专门管理Hibernate

此时该配置文件配置如下:

<?xml version="1.0" encoding="UTF-8"?>
<beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
</beans>

直接点击Finish完成即可!至此Spring支持成功加入了!

加入Struts2的支持:

此处需要注意的是在加Spring支持的时候,已经加入了antlr-2.7.6.jar的包,所以此处要勾选高级选项,将antlr-2.7.2.jar的复选框取消,点击finish完成即可!至此Struts2的支持加好!

最后一步:加入Hibernate支持:

在加Hibernate支持之前,先要配置好数据库的链接:

此界面找不到的朋友还请自行百度查询!

此处1的地方要勾选上!

2的地方就是将Hibernate交给Spring管理!

3的

选择刚才创建好的数据库链接!

点击finish完成即可!

此时各配置文件配置如下:

applicationContext-hibernate.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
    <context:annotation-config></context:annotation-config>
    <context:component-scan base-package="com.ssh.dao.impl,com.ssh.service.impl"></context:component-scan>
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
        <property name="url" value="jdbc:mysql://localhost:3306/ssh"></property>
        <property name="username" value="root"></property>
        <property name="password" value="admin"></property>
    </bean>
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="dataSource">
            <ref bean="dataSource" />
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">
                    org.hibernate.dialect.MySQLDialect
                </prop>
            </props>
        </property>
        <property name="mappingResources">
            <list>
                <value>com/ssh/pojo/SysRole.hbm.xml</value>
                <value>com/ssh/pojo/SysUser.hbm.xml</value></list>
        </property>
    </bean>
</beans>

struts.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
</struts>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
  <display-name>SSH</display-name>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:applicationContext-*.xml</param-value>
  </context-param>
  <filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>*.action</url-pattern>
  </filter-mapping>
</web-app>

框架支持加完之后,下面正式进入登录功能的开发!

数据库中我预先准备了一些数据,SQL代码如下:

/*
Navicat MySQL Data Transfer
Source Server         : 本机服务器
Source Server Version : 50533
Source Host           : localhost:3306
Source Database       : platform
Target Server Type    : MYSQL
Target Server Version : 50533
File Encoding         : 65001
Date: 2014-05-09 20:12:53
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for sys_role
-- ----------------------------
DROP TABLE IF EXISTS `sys_role`;
CREATE TABLE `sys_role` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `roleName` varchar(255) NOT NULL COMMENT ‘角色名称‘,
  `depart` int(11) DEFAULT NULL COMMENT ‘权限(部门)‘,
  `roleNum` varchar(2000) DEFAULT NULL COMMENT ‘角色权限‘,
  `field1` varchar(255) DEFAULT NULL COMMENT ‘备用字段1‘,
  `field2` varchar(255) DEFAULT NULL COMMENT ‘备用字段2‘,
  `field3` varchar(255) DEFAULT NULL COMMENT ‘备用字段3‘,
  `field4` varchar(255) DEFAULT NULL COMMENT ‘备用字段4‘,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sys_role
-- ----------------------------
-- ----------------------------
-- Table structure for sys_user
-- ----------------------------
DROP TABLE IF EXISTS `sys_user`;
CREATE TABLE `sys_user` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `userName` varchar(255) NOT NULL COMMENT ‘用户名‘,
  `userPwd` varchar(255) NOT NULL COMMENT ‘密码‘,
  `userNike` varchar(255) NOT NULL COMMENT ‘用户昵称‘,
  `userMail` varchar(255) DEFAULT NULL COMMENT ‘邮箱‘,
  `userPhone` varchar(255) DEFAULT NULL COMMENT ‘手机‘,
  `userTel` varchar(255) DEFAULT NULL COMMENT ‘电话‘,
  `userLastTime` varchar(255) DEFAULT NULL COMMENT ‘最后登录时间‘,
  `userLastIp` varchar(255) DEFAULT NULL COMMENT ‘最后登录IP‘,
  `userCompany` varchar(255) DEFAULT NULL COMMENT ‘单位名称‘,
  `roleid` int(11) DEFAULT NULL,
  `field1` varchar(255) DEFAULT NULL COMMENT ‘备用字段1‘,
  `field2` varchar(255) DEFAULT NULL COMMENT ‘备用字段2‘,
  `field3` varchar(255) DEFAULT NULL COMMENT ‘备用字段3‘,
  `field4` varchar(255) DEFAULT NULL COMMENT ‘备用字段4‘,
  PRIMARY KEY (`id`),
  KEY `roleid` (`roleid`),
  CONSTRAINT `sys_user_ibfk_1` FOREIGN KEY (`roleid`) REFERENCES `sys_role` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sys_user
-- ----------------------------
INSERT INTO `sys_user` VALUES (‘1‘, ‘admin‘, ‘admin‘, ‘管理员‘, null, null, null, null, null, null, null, null, null, null, null);

通过Hibernate生产映射:

生成映射之后,在src目录下会有如下的包:

SysRole.java

package com.ssh.pojo;
@SuppressWarnings("serial")
public class SysRole implements java.io.Serializable {
    private Integer id;
    private String roleName;
    private Integer depart;
    private String roleNum;
    private String field1;
    private String field2;
    private String field3;
    private String field4;
    public SysRole() {
    }
    public SysRole(String roleName) {
        this.roleName = roleName;
    }
    public SysRole(String roleName, Integer depart, String roleNum,
            String field1, String field2, String field3, String field4) {
        this.roleName = roleName;
        this.depart = depart;
        this.roleNum = roleNum;
        this.field1 = field1;
        this.field2 = field2;
        this.field3 = field3;
        this.field4 = field4;
    }
    public Integer getId() {
        return this.id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    public String getRoleName() {
        return this.roleName;
    }
    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }
    public Integer getDepart() {
        return this.depart;
    }
    public void setDepart(Integer depart) {
        this.depart = depart;
    }
    public String getRoleNum() {
        return this.roleNum;
    }
    public void setRoleNum(String roleNum) {
        this.roleNum = roleNum;
    }
    public String getField1() {
        return this.field1;
    }
    public void setField1(String field1) {
        this.field1 = field1;
    }
    public String getField2() {
        return this.field2;
    }
    public void setField2(String field2) {
        this.field2 = field2;
    }
    public String getField3() {
        return this.field3;
    }
    public void setField3(String field3) {
        this.field3 = field3;
    }
    public String getField4() {
        return this.field4;
    }
    public void setField4(String field4) {
        this.field4 = field4;
    }
}


SysUser.java

package com.ssh.pojo;
@SuppressWarnings("serial")
public class SysUser implements java.io.Serializable {
    private Integer id;
    private SysRole sysRole;
    private String userName;
    private String userPwd;
    private String userNike;
    private String userMail;
    private String userPhone;
    private String userTel;
    private String userLastTime;
    private String userLastIp;
    private String userCompany;
    private String field1;
    private String field2;
    private String field3;
    private String field4;
    public SysUser() {
    }
    public SysUser(String userName, String userPwd, String userNike) {
        this.userName = userName;
        this.userPwd = userPwd;
        this.userNike = userNike;
    }
    public SysUser(SysRole sysRole, String userName, String userPwd,
            String userNike, String userMail, String userPhone, String userTel,
            String userLastTime, String userLastIp, String userCompany,
            String field1, String field2, String field3, String field4) {
        this.sysRole = sysRole;
        this.userName = userName;
        this.userPwd = userPwd;
        this.userNike = userNike;
        this.userMail = userMail;
        this.userPhone = userPhone;
        this.userTel = userTel;
        this.userLastTime = userLastTime;
        this.userLastIp = userLastIp;
        this.userCompany = userCompany;
        this.field1 = field1;
        this.field2 = field2;
        this.field3 = field3;
        this.field4 = field4;
    }
    public Integer getId() {
        return this.id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    public SysRole getSysRole() {
        return this.sysRole;
    }
    public void setSysRole(SysRole sysRole) {
        this.sysRole = sysRole;
    }
    public String getUserName() {
        return this.userName;
    }
    public void setUserName(String userName) {
        this.userName = userName;
    }
    public String getUserPwd() {
        return this.userPwd;
    }
    public void setUserPwd(String userPwd) {
        this.userPwd = userPwd;
    }
    public String getUserNike() {
        return this.userNike;
    }
    public void setUserNike(String userNike) {
        this.userNike = userNike;
    }
    public String getUserMail() {
        return this.userMail;
    }
    public void setUserMail(String userMail) {
        this.userMail = userMail;
    }
    public String getUserPhone() {
        return this.userPhone;
    }
    public void setUserPhone(String userPhone) {
        this.userPhone = userPhone;
    }
    public String getUserTel() {
        return this.userTel;
    }
    public void setUserTel(String userTel) {
        this.userTel = userTel;
    }
    public String getUserLastTime() {
        return this.userLastTime;
    }
    public void setUserLastTime(String userLastTime) {
        this.userLastTime = userLastTime;
    }
    public String getUserLastIp() {
        return this.userLastIp;
    }
    public void setUserLastIp(String userLastIp) {
        this.userLastIp = userLastIp;
    }
    public String getUserCompany() {
        return this.userCompany;
    }
    public void setUserCompany(String userCompany) {
        this.userCompany = userCompany;
    }
    public String getField1() {
        return this.field1;
    }
    public void setField1(String field1) {
        this.field1 = field1;
    }
    public String getField2() {
        return this.field2;
    }
    public void setField2(String field2) {
        this.field2 = field2;
    }
    public String getField3() {
        return this.field3;
    }
    public void setField3(String field3) {
        this.field3 = field3;
    }
    public String getField4() {
        return this.field4;
    }
    public void setField4(String field4) {
        this.field4 = field4;
    }
}

applicationContext-hibernate多出如下代码,用于让项目启动时加载到实体类

<property name="mappingResources">
    <list>
        <value>com/ssh/pojo/SysRole.hbm.xml</value>
        <value>com/ssh/pojo/SysUser.hbm.xml</value></list>
</property>

SysUserDAO.java

package com.ssh.dao;
public interface SysUserDAO <K ,V>{
    /**
     * 登录方法
     * @param userName  用户名
     * @param passWord  密码
     * @return
     */
    public V login(String userName,String passWord);
}

在DAOImpl中要注入HibernateTemplate

因此ApplicationContext-hibernate.xml加入如下配置:

<?xml version="1.0" encoding="UTF-8"?>
<beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
    <context:annotation-config></context:annotation-config>
    <context:component-scan base-package="com.ssh.dao.impl,com.ssh.service.impl"></context:component-scan>
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
        <property name="url" value="jdbc:mysql://localhost:3306/ssh"></property>
        <property name="username" value="root"></property>
        <property name="password" value="admin"></property>
    </bean>
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="dataSource">
            <ref bean="dataSource" />
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">
                    org.hibernate.dialect.MySQLDialect
                </prop>
            </props>
        </property>
        <property name="mappingResources">
            <list>
                <value>com/ssh/pojo/SysRole.hbm.xml</value>
                <value>com/ssh/pojo/SysUser.hbm.xml</value></list>
        </property>
    </bean>
    <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
        <property name="sessionFactory">
            <ref bean="sessionFactory"/>
        </property>
    </bean>
</beans>

SysUserDAOImpl.java

package com.ssh.dao.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.ssh.dao.SysUserDAO;
import com.ssh.pojo.SysUser;
public class SysUserDAOImpl extends HibernateDaoSupport implements SysUserDAO<Integer, SysUser> {

    @Autowired
    public SysUserDAOImpl(HibernateTemplate hibernateTemplate){
        super.setHibernateTemplate(hibernateTemplate);
    }

    /**
     * 登录
     */
    @SuppressWarnings("unchecked")
    public SysUser login(String userName, String passWord) {
        String hql = "FROM SysUser where userName = ? and userPwd = ?";
        List<SysUser> list = super.getHibernateTemplate().find(hql , userName , passWord);
        if(list.size() > 0){
            return list.get(0);
        }else{
            return null;
        }
    }
}

SysUserService.java

package com.ssh.service;
import com.ssh.pojo.SysUser;
public interface SysUserService {
    /**
     * 登录
     * @param userName 用户名
     * @param passWord 密码
     * @return
     */
    public SysUser login(String userName , String passWord);
}

SysUserServiceImpl.java

package com.ssh.service.impl;
import com.ssh.dao.SysUserDAO;
import com.ssh.pojo.SysUser;
import com.ssh.service.SysUserService;
public class SysUserServiceImpl implements SysUserService {

    private SysUserDAO<Integer, SysUser> sysUserDAO;
    public SysUser login(String userName, String passWord) {
        return sysUserDAO.login(userName, passWord);
    }

    //通过set方法注入dao
    public void setSysUserDAO(SysUserDAO<Integer, SysUser> sysUserDAO) {
        this.sysUserDAO = sysUserDAO;
    }

}

加入两个新的配置用来注入DAO和Service

applicationContext-action.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
    <bean id="login" class="com.ssh.action.UserAction">
        <property name="sysUserService" ref="sysUserService"></property>
    </bean>
</beans>

applicationContext-service.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
    <!-- 首字母不要大写,会报错 -->
    <bean id="sysUserDAO" class="com.ssh.dao.impl.SysUserDAOImpl">
        <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>
    <bean id="sysUserService" class="com.ssh.service.impl.SysUserServiceImpl">
        <property name="sysUserDAO" ref="sysUserDAO"></property>
    </bean>
</beans>

编写Action:

UserAction.java

package com.ssh.action;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.ssh.pojo.SysUser;
import com.ssh.service.SysUserService;
@SuppressWarnings("serial")
public class UserAction extends ActionSupport{
    private HttpServletRequest request = ServletActionContext.getRequest();
    private String userName;
    private String passWord;
    private SysUserService sysUserService;
    public String login(){
        SysUser user = sysUserService.login(userName, passWord);
        if(user != null){
            request.getSession().setAttribute("user", user);        //登录成功之后将登录用户放入session
            return "success";
        }else{
            return "input";             //返回错误页
        }

    }
    public void setSysUserService(SysUserService sysUserService) {
        this.sysUserService = sysUserService;
    }
    public String getUserName() {
        return userName;
    }
    public void setUserName(String userName) {
        this.userName = userName;
    }
    public String getPassWord() {
        return passWord;
    }
    public void setPassWord(String passWord) {
        this.passWord = passWord;
    }
    public HttpServletRequest getRequest() {
        return request;
    }
    public void setRequest(HttpServletRequest request) {
        this.request = request;
    }

}

login.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>登录</title>
  </head>

  <body>
    <form action="login.action" method="post">
        用户名:<input name="userName" type="text" />
        密码:<input name="passWord" type="password" />
        <input type="submit" value="login" />
    </form>
  </body>
</html>

index.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
  </head>

  <body>
        欢迎${user.userNike}登录!!!<br>
  </body>
</html>

Struts2+Spring3.1+Hibernate3.3的整个项目,布布扣,bubuko.com

时间: 2024-11-05 15:52:47

Struts2+Spring3.1+Hibernate3.3的整个项目的相关文章

SSH (Struts2+Spring3.0+Hibernate3)框架(一) 理论

典型的J2EE三层结构,分为表现层.中间层(业务逻辑层)和数据服务层.三层体系将业务规则.数据访问及合法性校验等工作放在中间层处理.客户端不直接与数据库交互,而是通过组件与中间层建立连接,再由中间层与数据库交互.   表现层是传统的JSP技术,自1999年问世以来,经过多年的发展,其广泛的应用和稳定的表现,为其作为表现层技术打下了坚实的基础.   中间层采用的是流行的Spring+Hibernate,为了将控制层与业务逻辑层分离,又细分为以下几种. Web层,就是MVC模式里面的“C”(cont

SSH项目整合教学Eclipse搭建SSH(Struts2+Spring3+Hibernate3)

这篇博文的目的 尝试搭建一个完整的SSH框架项目. 给以后的自己,也给别人一个参考. 读博文前应该注意: 本文提纲:本文通过一个用户注册的实例讲解SSH的整合.创建Struts项目,整合Hibernate,整合Spring.最后总结如何熟练创建SSH项目. 仅是创建SSH项目,对于其他的扩展例如Struts的国际化,Hibernate的缓存优化,Spring的AOP等,本博文涉及不到.想学习更多的东西请搜索其他博文. 本项目的环境:Windows 8-64位,Eclipse Indigo Ser

MyEclipse搭建SSH框架 Struts2.1+Spring3.0+hibernate3.3

1.         配置Tomcat 配置Tomcat所在路径 配置Tomcat使用JDK版本 如果Tomcat为7.0则添加Tomcat-juli.jar包 2.         new一个web project. 2.右键项目,为项目添加Struts支持. 点击Finish.src目录下多了struts.xml配置文件. 3.使用MyEclipse DataBase Explorer建立数据源. new一个数据源.填入数据源信息. jdbc:Oracle:thin:@localhost(数

使用Maven搭建Struts2+Spring3+Hibernate4的整合开发环境

做了三年多的JavaEE开发了,在平时的JavaEE开发中,为了能够用最快的速度开发项目,一般都会选择使用Struts2,SpringMVC,Spring,Hibernate,MyBatis这些开源框架来开发项目,而这些框架一般不是单独使用的,经常是Struts2+Spring3+Hibernate.SpringMVC+Spring+Hibernate.SpringMVC+Spring+Mybatis这几种组合中的一种,也就是多个框架配合起来使用.今天来总结一下如何使用Maven搭建Struts

Struts2+Spring3+Hibernate——整合byMaven

在平时的JavaEE开发中,为了能够用最快的速度开发项目,一般都会选择使用Struts2,SpringMVC,Spring,Hibernate,MyBatis这些开源框架来开发项目,而这些框架一般不是单独使用的,经常是Struts2+Spring3+Hibernate.SpringMVC+Spring+Hibernate.SpringMVC+Spring+Mybatis这几种组合中的一种,也就是多个框架配合起来使用.今天来总结一下如何使用Maven搭建Struts2+Spring3+Hibern

Maven搭建Struts2+Spring3+Hibernate4框架

做了三年多的JavaEE开发了,在平时的JavaEE开发中,为了能够用最快的速度开发项目,一般都会选择使用Struts2,SpringMVC,Spring,Hibernate,MyBatis这些开源框架来开发项目,而这些框架一般不是单独使用的,经常是Struts2+Spring3+Hibernate.SpringMVC+Spring+Hibernate.SpringMVC+Spring+Mybatis这几种组合中的一种,也就是多个框架配合起来使用.今天来总结一下如何使用Maven搭建Struts

Struts2,Spring3,Hibernate4整合--SSH框架

Struts2,Spring3,Hibernate4整合--SSH框架(学习中) 一.包的导入 1.Spring包 2.Hibernate 包 3.struts 包 4.数据库方面的包及junt4的包 二.配置文件 1.beans.xml (具体要注意的已经注释到 xml 中了,目前整合了Spring 与 hibernate4 ) <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="h

Struts2+Spring3+Mybatis3开发环境搭建

本文主要介绍Struts2+Spring3+Mybatis3开发环境搭建 Struts和Spring不过多介绍. MyBatis 是支持普通 SQL 查询,存储过程和高级映射的优秀持久层框架.MyBatis 消除了几乎所有的 JDBC 代码和参数的手工设置以及结果集的检索.MyBatis 使用简单的 XML 或注解用于配置和原始映射,将接口和 Java 的 POJOs(Plan Old Java Objects,普通的 Java 对象)映射成数据库中的记录. 环境: Struts-2.3.14

Struts2+Spring3.2+ibatis2.3整合

Struts2+Spring3.2+ibatis2.3整合 转自:http://blog.163.com/[email protected]/blog/static/1032422412013330105358161/ 一.代码目录结构: 二.web.xml配置:(集成struts.spring) <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmln