applicationContext.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:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd "> <!-- 加载db.properties文件 -->
<bean id="config" class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer">
<property name="locations" value="classpath*:*.properties"/>
</bean> <!-- 配置配置数据库信息(替代mybatis的配置文件conf.xml) -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${driver}"></property>
<property name="url" value="${url}"></property>
<property name="username" value="${username}"></property>
<property name="password" value="${password}"></property>
<property name="initialSize" value="${initialSize}"></property>
<property name="maxActive" value="${maxActive}"></property>
<property name="maxIdle" value="${maxIdle}"></property>
<property name="minIdle" value="${minIdle}"></property>
</bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<!-- //加载实体类的映射文件位置及名称 -->
<property name="mappingLocations" value="classpath:k/bean/*.hbm.xml"></property>
<property name="configLocation" value="classpath:hibernate.cfg.xml"></property>
</bean> <!--事务-->
<bean id="txManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean> <!--开启注解配置-->
<context:annotation-config/> <!--配置 action-->
<bean name="/login" class="k.action.LoginAction" scope="prototype"/>
<bean name="/employee" class="k.action.EmployeeAction" scope="prototype"/> <!--配置 Service-->
<bean name="testService" class="k.service.TestService"/>
<bean name="employeeService" class="k.service.impl.EmployeeServiceImpl"/>
<bean name="departmentService" class="k.service.impl.DepartmentServiceImpl"/> </beans>

struts-config.xml

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://struts.apache.org/dtds/struts-config_1_3.dtd"> <struts-config> <form-beans>
<form-bean name="employeeForm" type="k.form.EmployeeForm">
<form-property name="id" type="java.lang.Integer"></form-property>
<form-property name="name" type="java.lang.String"></form-property>
<form-property name="password" type="java.lang.String"></form-property>
</form-bean>
</form-beans> <global-forwards>
<forward name="ok" path="/WEB-INF/jsp/ok.jsp"></forward>
<forward name="err" path="/WEB-INF/jsp/err.jsp"></forward>
</global-forwards> <action-mappings>
<action name="employeeForm" path="/login" parameter="action" type="k.action.LoginAction"
scope="request" attribute="employeeForm" input="index.jsp" validate="false">
<forward name="main" path="/WEB-INF/jsp/main.jsp"></forward>
<forward name="loginJsp" path="/WEB-INF/jsp/login.jsp"></forward>
</action>
<action name="employeeForm" path="/employee" parameter="action" type="k.action.EmployeeAction"
scope="request" attribute="employeeForm" input="index.jsp" validate="false">
<forward name="addEmployeeUI" path="/WEB-INF/jsp/addEmployeeUI.jsp"></forward>
<forward name="loginJsp" path="/WEB-INF/jsp/login.jsp"></forward>
</action>
</action-mappings> <controller>
<set-property property="processorClass"
value="org.springframework.web.struts.DelegatingRequestProcessor"></set-property>
</controller> </struts-config>

hibernate.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- 配置Hibernate的基本属性 -->
<!-- 1.数据源配置到IOC容器中 -->
<!-- 2.关联的.hbm.xml也在IOC容器配置SessionFactory实例 -->
<!-- 3.配置Hibernate的基本属性:方言,SQL显示及格式化,生成数据表的策略以及二级缓存 -->
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
<property name="cache.use_second_level_cache">true</property>
<property name="ache.provider_class">org.hibernate.cache.internal.DefaultCacheKeysFactory</property>
<property name="generate_statistics">true</property>
</session-factory>
</hibernate-configuration>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1"> <!-- spring 初始化 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
<listener-class>k.listener.StartSystemListener</listener-class>
<!--<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>-->
</listener> <!-- struts 初始化 -->
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping> <!-- 配置请求过滤器,编码格式设为UTF-8,避免中文乱码-->
<filter>
<filter-name>springUtf8Encoding</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>springUtf8Encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!--<filter>-->
<!--<filter-name>EncodingFilter</filter-name>-->
<!--<filter-class>k.listener.EncodingFilter</filter-class>-->
<!--</filter>-->
<!--<filter-mapping>-->
<!--<filter-name>EncodingFilter</filter-name>-->
<!--<url-pattern>/*</url-pattern>-->
<!--</filter-mapping>--> <!-- 懒加载 -->
<filter>
<filter-name>OpenSessionInViewFilter</filter-name>
<filter-class>org.springframework.orm.hibernate5.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>OpenSessionInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <!-- 以下3项参数与log4j的配置相关 -->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:log4j.properties</param-value>
</context-param> <context-param>
<param-name>log4jRefreshInterval</param-name>
<param-value>60000</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.util.Log4jConfigListener
</listener-class>
</listener> </web-app>
db.properties
driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8
username=root
password=xxxx
initialSize=20
maxActive=500
maxIdle=2
minIdle=1

log4j.properties

log4j.rootLogger=ERROR, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.conversionPattern=%5p [%t] (%F:%L) - %m%n
EmployeeAction
package k.action;

import k.domain.Department;
import k.domain.Employee;
import k.form.EmployeeForm;
import k.service.DepartmentService;
import k.service.EmployeeService;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date; public class EmployeeAction extends DispatchAction { @Resource
private EmployeeService employeeService;
@Resource
private DepartmentService departmentService; public ActionForward addEmployeeUI(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
return mapping.findForward("addEmployeeUI");
} public ActionForward addEmployee(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
EmployeeForm employeeForm = (EmployeeForm) form;
Employee employee = new Employee();
employee.setName(employeeForm.getName());
employee.setEmail(employeeForm.getEmail());
employee.setSalary(employeeForm.getSalary());
employee.setPassword(employeeForm.getPassword());
employee.setGrade(employeeForm.getGrade());
employee.setHireDate(new Date());
Department department = departmentService.getDepartmentbyEmployee(Integer.parseInt(employeeForm.getDepartment_id()));
employee.setDepartment(department);
try {
employeeService.addEmployee(employee);
} catch (Exception e) {
e.printStackTrace();
return mapping.findForward("err");
}
return mapping.findForward("ok");
}
}
LoginAction
package k.action;

import k.domain.Employee;
import k.form.EmployeeForm;
import k.service.EmployeeService;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; public class LoginAction extends DispatchAction { @Resource
private EmployeeService employeeService; public ActionForward login(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
return mapping.findForward("loginJsp");
} public ActionForward doLogin(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
EmployeeForm employeeOld = (EmployeeForm) form;
Employee employee = new Employee(Integer.parseInt(employeeOld.getId()), employeeOld.getPassword());
employee = employeeService.checkEmployee(employee);
if (employee != null) {
request.getSession().setAttribute("employee", employee);
return mapping.findForward("main");
}
return mapping.findForward("err");
} public ActionForward loginOut(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
return super.execute(mapping, form, request, response);
}
}

Department.hbm.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="k.domain.Department" table="t_department">
<!--<cache usage="read-write"></cache>-->
<id name="id" column="id" type="java.lang.Integer">
<generator class="native"></generator>
</id>
<property name="name" column="name" type="java.lang.String" length="64"></property>
<!-- 在客户映射文件中,表示所有联系人
使用set标签表示所有联系人
set标签里面有name属性:
属性值写在客户实体类里面表示联系人的set集合名称 inverse属性默认值:false不放弃关系维护
true 表示放弃关系维护
-->
<set name="employees" inverse="true" cascade="save-update,delete">
<!-- 一对多建表,有外键
hibernate机制:双向维护外键,在一和多那一方都配置外键
column属性值:外键名称
-->
<key column="department_id"></key>
<one-to-many class="k.domain.Employee"></one-to-many>
</set>
</class>
</hibernate-mapping>

Employee.hbm.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="k.domain.Employee" table="t_employee">
<id name="id" column="id" type="java.lang.Integer">
<!-- 设置数据库表id增长策略 native:生成表id值就是主键自动增长 uuid -->
<generator class="native"></generator>
</id>
<!-- 配置其他属性和表字段对应 name属性:实体类属性名称 column属性:生成表字段名称 -->
<property name="name" column="name" type="java.lang.String" length="64"></property>
<property name="email" column="email" type="java.lang.String" length="64"></property>
<property name="hireDate" column="hireDate" type="java.util.Date"></property>
<property name="salary" column="salary" type="java.lang.Float"></property>
<property name="password" column="password" type="java.lang.String" length="64"></property>
<property name="grade" column="grade" type="java.lang.Integer" length="3"></property>
<many-to-one name="department" class="k.domain.Department" column="department_id"></many-to-one>
</class>
</hibernate-mapping>
Department
package k.domain;

import java.util.Set;

public class Department {
private Integer id;
private String name;
private Set<Employee> employees; public Department() {
} public Department(String name) {
this.name = name;
} public Integer getId() { return id;
} public void setId(Integer id) {
this.id = id;
} public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} public Set<Employee> getEmployees() {
return employees;
} public void setEmployees(Set<Employee> employees) {
this.employees = employees;
}
}
Employee
package k.domain;

import java.util.Date;

public class Employee {
private Integer id;
private String name;
private String email;
private Date hireDate;
private Float salary;
private String password;
private Integer grade;
private Department department;
private String department_id; public Employee(Integer id, String name) {
this.id = id;
this.name = name;
} public Employee() {
} public Employee(String name, String password, String email, Date hireDate, Float salary, Integer grade) {
this.name = name;
this.email = email;
this.hireDate = hireDate;
this.salary = salary;
this.password = password;
this.grade = grade;
} public String getDepartment_id() {
return department_id;
} public void setDepartment_id(String department_id) {
this.department_id = department_id;
} public Integer getId() { return id;
} public void setId(Integer id) {
this.id = id;
} public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} public String getEmail() {
return email;
} public void setEmail(String email) {
this.email = email;
} public Date getHireDate() {
return hireDate;
} public void setHireDate(Date hireDate) {
this.hireDate = hireDate;
} public Float getSalary() {
return salary;
} public void setSalary(Float salary) {
this.salary = salary;
} public String getPassword() {
return password;
} public void setPassword(String password) {
this.password = password;
} public Integer getGrade() {
return grade;
} public void setGrade(Integer grade) {
this.grade = grade;
} public Department getDepartment() {
return department;
} public void setDepartment(Department department) {
this.department = department;
} }
EmployeeForm
package k.form;

import org.apache.struts.action.ActionForm;

import java.util.Date;

public class EmployeeForm extends ActionForm {
private String id;
private String name;
private String email;
private Date hireDate;
private Float salary;
private String password;
private Integer grade;
private String department_id; public String getEmail() {
return email;
} public void setEmail(String email) {
this.email = email;
} public Date getHireDate() {
return hireDate;
} public void setHireDate(Date hireDate) {
this.hireDate = hireDate;
} public Float getSalary() {
return salary;
} public void setSalary(Float salary) {
this.salary = salary;
} public Integer getGrade() {
return grade;
} public void setGrade(Integer grade) {
this.grade = grade;
} public String getDepartment_id() {
return department_id;
} public void setDepartment_id(String department_id) {
this.department_id = department_id;
} public String getPassword() {
return password;
} public void setPassword(String password) {
this.password = password;
} public String getId() {
return id;
} public void setId(String id) {
this.id = id;
} public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} }
EncodingFilter
package k.listener;

import javax.servlet.*;
import javax.servlet.http.HttpServlet;
import java.io.IOException; public class EncodingFilter extends HttpServlet implements Filter {
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse,
FilterChain filterChain) throws IOException, ServletException {
servletRequest.setCharacterEncoding("utf-8");
servletResponse.setCharacterEncoding("utf-8");
// System.out.println("========== set utf-8 ok ==========");
filterChain.doFilter(servletRequest, servletResponse);
} @Override
public void init(FilterConfig filterConfig) throws ServletException { }
}
StartSystemListener
package k.listener;

import k.util.WebHelper;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener; public class StartSystemListener implements ServletContextListener {
@Override
public void contextInitialized(ServletContextEvent sce) {
//1.将项目上下文路径(request.getContextPath())放置到application域中.
ServletContext application = sce.getServletContext();
String app_path = application.getContextPath();
application.setAttribute("APP_PATH", app_path);
System.out.println("========== APP_PATH = " + app_path);
WebHelper.setApp_Path(app_path);
} @Override
public void contextDestroyed(ServletContextEvent sce) { }
}
DepartmentServiceImpl
package k.service.impl;

import k.domain.Department;
import k.domain.Employee;
import k.service.DepartmentService;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource;
import java.io.Serializable; @Transactional
public class DepartmentServiceImpl implements DepartmentService { @Resource
private SessionFactory sessionFactory; @Override
public void addDepartment(Department department) {
Session session = sessionFactory.openSession();
// Transaction transaction = session.beginTransaction();
Serializable res = session.save(department);
// transaction.commit();
} @Override
public Department getDepartmentbyEmployee(Serializable id) {
Session session = sessionFactory.openSession();
Department department = session.get(Department.class, id);
return department;
}
}
EmployeeServiceImpl
package k.service.impl;

import k.domain.Department;
import k.domain.Employee;
import k.service.EmployeeService;
import org.hibernate.*;
import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List; @Transactional
public class EmployeeServiceImpl implements EmployeeService { @Resource
private SessionFactory sessionFactory; @Override
public int addEmployee(Employee e) {
Session session = sessionFactory.openSession();
Transaction transaction = session.beginTransaction();
Serializable res = session.save(e);
transaction.commit();
return (Integer) res;
} @Override
public List<Employee> getList() {
return null;
} @Override
public int updateEmployee() {
return 0;
} @Override
public int delEmployee(Serializable id) {
return 0;
} @Override
public Employee checkEmployee(Employee e) {
Session session = sessionFactory.openSession();
Query sqlQuery = session.createQuery("from k.domain.Employee c where c.id=? ");
// SQLQuery sqlQuery = session.createSQLQuery("select * from t_employee where id=?");
sqlQuery.setParameter(0, e.getId());
// Hibernate.initialize(Department.class); //显示初始化懒加载
List<Employee> list = sqlQuery.list();
if (list.size() == 1) {
// Department department = list.get(0).getDepartment();
// String s1 = department.getId() + "===3" + department.getName();
// System.out.println(department.getId() + "===3" + department.getName());
return list.get(0);
}
return null;
}
}
DepartmentService
package k.service;

import k.domain.Department;
import java.io.Serializable; public interface DepartmentService {
void addDepartment(Department department); Department getDepartmentbyEmployee(Serializable id);
}
EmployeeService
package k.service;

import k.domain.Employee;

import java.io.Serializable;
import java.util.List; public interface EmployeeService {
int addEmployee(Employee e); List<Employee> getList(); int updateEmployee(); int delEmployee(Serializable id); Employee checkEmployee(Employee e);
}
WebHelper
package k.util;

import java.util.UUID;

public class WebHelper {

    public static String getApp_Path() {
return APP_PATH;
} public static void setApp_Path(String appPath) {
APP_PATH = appPath;
} private static String APP_PATH = ""; public static String getNewFileName(String fileName) {
int beginIndex = fileName.lastIndexOf(".");
return UUID.randomUUID().toString() + fileName.substring(beginIndex, fileName.length());
}
}

addEmployeeUI.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>添加雇员</title>
</head>
<body>
<h1>添加雇员</h1>
<form action="${APP_PATH}/employee.do?action=addEmployee" method="post">
<table>
<tr>
<td>name:</td>
<td><input type="text" name="name" value="张三4"></td>
</tr>
<tr>
<td>email:</td>
<td><input type="text" name="email" value="zhangsan@qq.com"></td>
</tr>
<tr>
<td>salary:</td>
<td><input type="text" name="salary" value="5000"></td>
</tr>
<tr>
<td>password:</td>
<td><input type="password" name="password" value="1"></td>
</tr>
<tr>
<td>grade:</td>
<td><input type="text" name="grade" value="1"></td>
</tr>
<tr>
<td>department_id:</td>
<td><select name="department_id">
<option value="1" selected>部门1</option>
</select></td>
</tr>
<tr>
<td><input type="submit" name="sub1" value="添加"></td>
<td><input type="reset" name="reset" value="重置"></td>
</tr>
</table>
</form>
</body>
</html>

login.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>管理员登录</title>
</head>
<body>
<h1>管理员登录</h1>
<form action="${APP_PATH}/login.do?action=doLogin" method="post">
<table>
<tr>
<td>id:</td>
<td><input type="text" name="id" value="1"></td>
</tr>
<tr>
<td>name:</td>
<td><input type="text" name="name" value="1哈哈"></td>
</tr>
<tr>
<td>pwd:</td>
<td><input type="password" name="password" value="1"></td>
</tr>
<tr>
<td><input type="submit" name="sub1" value="登录"></td>
<td><input type="reset" name="reset" value="重置"></td>
</tr>
</table>
</form>
</body>
</html>

main.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>登录成功</title>
</head>
<body>
<h1>登录成功</h1>
<a href="${APP_PATH}/login.do?action=login">返回登录</a>
<h2>欢迎 【${employee.name}】 您所在的部门是 【${employee.getDepartment().getName()} 】请选择您要进行的操作</h2>
<a href="${APP_PATH}/employee.do?action=addEmployeeUI">添加雇员</a> <br/>
<a href="#">显示雇员</a> <br/>
<a href="#">查询雇员</a> <br/>
<a href="#">退出系统</a> <br/>
</body>
</html>

ok.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>成功</title>
</head>
<body>
<h1>成功</h1>
<a href="#">返回继续添加</a>
<a href="#">返回主界面</a>
<a href="${APP_PATH}/login.do?action=login">返回登录</a>
</body>
</html>

err.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>操作失败</title>
</head>
<body>
<h1>操作失败</h1>
<a href="#">操作失败,返回主界面</a>
<a href="${APP_PATH}/login.do?action=login">返回登录</a>
</body>
</html>

index.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>$Title$</title>
</head>
<body>
<jsp:forward page="WEB-INF/jsp/login.jsp"></jsp:forward>
</body>
</html>

【 SSH 整合】Spring、Struts、Hibernate基本整合的更多相关文章

  1. 整合spring和hibernate框架

    一)整合spring和hibernate框架整合要点:(1)数据源配置在Spring的配置文件中,供Spring和Hibernate框架共同使用:(2)不再需要hibernate.hbm.xml配置文 ...

  2. SSH(Spring SpringMVC Hibernate)框架整合

    项目说明: 使用SSH(Spring SpringMVC Hibernate)框架整合添加部门功能 项目结构   1.导入依赖jar包 <!--单测--> <dependency&g ...

  3. Spring+Struts2+Hibernate的整合

    这篇主要采用Maven搭建Spring+Struts2+Hibernate的整合项目,复习一下SSH框架,虽然spring提供自己的MVC框架, 但是Spring也提供和其他框架的无缝整合,采用组件形 ...

  4. spring和hibernate的整合

    阅读目录 一.概述 二.整合步骤 1.大致步骤 2.具体分析 一.概述 Spring整合Hibernate有什么好处? 1.由IOC容器来管理Hibernate的SessionFactory 2.让H ...

  5. SSH(Spring Struts2 Hibernate)框架整合(注解版)

    案例描述:使用SSH整合框架实现部门的添加功能 工程: Maven 数据库:Oracle 框架:Spring Struts2  Hibernate 案例架构: 1.依赖jar包 pom.xml < ...

  6. SSH(Spring Struts2 Hibernate)框架整合(xml版)

    案例描述:使用SSH整合框架实现部门的添加功能 工程: Maven 数据库:Oracle 案例架构: 1.依赖jar包pom.xml <project xmlns="http://ma ...

  7. Spring+Struts2+Hibernate框架整合流程

    一:基本步骤 新建Maven项目,导入相关依赖(推荐) 在WEB-INF的web.xml中进行配置 ————–Hibernate配置 —————- 创建entity包,创建数据库相关实体类 根据实体类 ...

  8. Spring 和 Hibernate的整合

    问题 ,spring 和 hibernate 整合 如何整合 1. Spring 使用Hibernate的的SessionFactory 2. Hibernate使用Spring提供的声明式事务

  9. 【spring 6】Spring和Hibernate的整合:编程式事务

    一.编程式事务简介 在 Spring 出现以前,编程式事务管理对基于 POJO 的应用来说是唯一选择.用过 Hibernate 的人都知道,我们需要在代码中显式调用beginTransaction() ...

  10. Spring+Struts+Hibernate 简介(转)

    http://blog.csdn.net/slnqnd/article/details/1772910/ Struts2.0 +Hibernate 3.2 +Spring 2.0 一.         ...

随机推荐

  1. git保存仓库的账号密码

    1.执行保存账号命令 # 保存本地仓库的账号git config --local credential.helper store # 保存git全局账号git config --global cred ...

  2. 解决pjax重复加载js导致事件重复绑定的问题

    个人博客 地址:http://www.wenhaofan.com/article/20180925232057 1.所有js统一在pjax容器外引入 在pjax容器外引入的js只会被引入一次,所以不会 ...

  3. MFC在子线程中创建窗口(PostMessage方法)

    1.创建子线程 C++创建线程的方式比较多 1)最简单易用的<thread>头文件,但是这种方法创建的子线程中无法给主线程PostMessage消息(也可能是我操作有误,总之没成功) 2) ...

  4. Spring整合MyBatis案例练习笔记

    需求: 用户登录 技术需求: Servlet+Spring+Mybatis+MVC+jsp+css+html+jquery 数据库设计: 用户表 Sql语句设计: select * from t_us ...

  5. fnt文字

    //fileName是fnt文件的path.在fnt文件的相同目录下有同名png文件.使用ShoeBox.exe生成fnt文件.在fnt文件中修改路径为类似number 及 number.png的格式 ...

  6. TC基础与自动化

    前言 互联网产品的测试常常要覆盖在不同网络下的表现,例如丢包,带宽受限,时延及抖动等网络较差的情况,为了测试场景的网络情况可定义及复现,就需要有个工具对弱网进行模拟.业界一些通用的弱网模拟工具,如NE ...

  7. C#设置WebBrowser使用Edge内核

    原文:C#设置WebBrowser使用Edge内核 1. 问题描述 用C#写了一个小工具, 需要显示网页上的内容, 但WebBrowser使用的是IE内核, 不能很好的展示网页 2. 解决方法 通过一 ...

  8. python3爬虫(4)各种网站视频下载方法

    python3爬虫(4)各种网站视频下载方法原创H-KING 最后发布于2019-01-09 11:06:23 阅读数 13608 收藏展开理论上来讲只要是网上(浏览器)能看到图片,音频,视频,都能够 ...

  9. eclipse的一些使用

    1.恢复默认视图 window->perspective->open perspective ->open java 2.打开其他的一些视图,比如server(tomcat,目前使用 ...

  10. 3 种比较 cmp

    结构体中的比较 struct dian{ int l,r; bool operator <(const dian &t)const { if(r==t.r) return l>t. ...