JavaWeb_(SSH)三大框架整合struts+hibernate+spring_Demo
三大框架整合
一、SSH导包
二、书写Spring
三、书写Struts
四、整合Spring与Struts
五、书写(与整合)Hibernate、引入c3p0连接池并使用hibernate模板
六、整合事务
--完成用户登录
项目已上传到github 传送门

在MySQL数据库中创建spring表,添加一条假数据

一、SSH导包
导入struts的jar包

导入spring的jar包

导入hibernate的jar包

导入c3p0连接池jar包和springapo的jar包,mysql链接数据库驱动包,第四个spring整合包暂时不需要导入,下文导入的时候会说!!!

二、书写Spring
准备applicationContext.xml作为spring的配置文件
<?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"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd"> </beans>
applicationContext.xml
编写web.xml
<!-- 让spring随着web项目的启动而启动 -->
<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>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>SSH</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list> <!-- 让spring随着web项目的启动而启动 -->
<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> </web-app>
web.xml
三、配置struts
准备struts.xml配置文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
"http://struts.apache.org/dtds/struts-2.5.dtd"> <struts>
</struts>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
"http://struts.apache.org/dtds/struts-2.5.dtd"> <struts>
</struts>
struts.xml
在web.xml中开启struts
<!-- 让struts启动 -->
<filter>
<filter-name>struts</filter-name>
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>SSH</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list> <!-- 让spring随着web项目的启动而启动 -->
<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> <!-- 让struts启动 -->
<filter>
<filter-name>struts</filter-name>
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> </web-app>
web.xml
四.1、书写Action,并在struts.xml中开启动态方法调用
package com.Gary.domain;
public class User {
private String id;
private String username;
private String password;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
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;
}
}
User.java
<?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 package="com.Gary.domain">
<!-- 配置包类和数据库中的哪个表对应 -->
<class name="User" table="user">
<!-- 主键 -->
<id name="id">
<generator class="uuid"></generator>
</id> <!-- 普通字段 -->
<property name="username" column="username"></property>
<property name="password" column="password"></property> </class> </hibernate-mapping>
User.hbm.xml
package com.Gary.web; import com.Gary.domain.User;
import com.Gary.service.UserService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven; public class UserAction extends ActionSupport implements ModelDriven<User>{ public User user = new User(); private UserService userService; public String execute() throws Exception { boolean success = userService.findUser(user); if(success)
{
return "toIndex";
}else {
ActionContext.getContext().put("error", "用户名或密码错误!!!");
return "login";
} } public UserService getUserService() {
return userService;
} public void setUserService(UserService userService) {
this.userService = userService;
} @Override
public User getModel() {
return user;
} }
UserAction.java
package com.Gary.service; import com.Gary.dao.UserDao;
import com.Gary.domain.User; public class UserService { private UserDao userDao; public boolean findUser(User user) { User temp = userDao.findUser(user); return temp == null?false:true;
} public UserDao getUserDao() {
return userDao;
} public void setUserDao(UserDao userDao) {
this.userDao = userDao;
} }
UserService.java
package com.Gary.dao; import org.hibernate.Session;
import org.hibernate.query.NativeQuery;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport; import com.Gary.domain.User; public class UserDao extends HibernateDaoSupport { public User findUser(User user) {
Session session = getHibernateTemplate().getSessionFactory().getCurrentSession(); String sql = "select * from user where username = ? and password = ?";
NativeQuery query = session.createSQLQuery(sql);
query.setParameter(1,user.getUsername());
query.setParameter(2, user.getPassword());
query.addEntity(User.class); User result = (User) query.uniqueResult(); return result;
} }
UserDao.java
<struts>
<!-- 开启动态方法调用 -->
<constant name="struts.devMode" value="true"></constant>
<constant name="struts.enable.DynamicMethodInvocation" value="true"></constant> <package name="ssh" namespace="/" extends="struts-default">
<!-- 允许所有方法 -->
<global-allowed-methods>regex:.*</global-allowed-methods>
<!-- 配置Action -->
<action name="UserAction_*" class="com.Gary.web.UserAction">
<!-- 配置结果集第一个为转发,第二个为重定向 -->
<result name="login">/login.jsp</result>
<result name="toIndex" type="redirect">/index.html</result>
</action>
</package> </struts>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
"http://struts.apache.org/dtds/struts-2.5.dtd"> <struts>
<!-- 开启动态方法调用 -->
<constant name="struts.devMode" value="true"></constant>
<constant name="struts.enable.DynamicMethodInvocation" value="true"></constant> <package name="ssh" namespace="/" extends="struts-default">
<!-- 允许所有方法 -->
<global-allowed-methods>regex:.*</global-allowed-methods>
<!-- 配置Action -->
<action name="UserAction_*" class="com.Gary.web.UserAction">
<!-- 配置结果集第一个为转发,第二个为重定向 -->
<result name="login">/login.jsp</result>
<result name="toIndex" type="redirect">/index.html</result>
</action>
</package> </struts>
struts.xml
提交登陆<form>表单
<form action="${pageContext.request.contextPath }/UserAction_login" method="post">
<div class="register-box">
<label for="username" class="username_label">
用 户 名
<input maxlength="20" name="username" type="text"
placeholder="您的用户名和登录名" />
</label>
<div class="tips">
</div>
</div>
<div class="register-box">
<label for="username" class="other_label">
密 码
<input maxlength="20" type="password" name="password"
placeholder="建议至少使用两种字符组合" />
</label>
<div class="tips">
</div>
</div>
<div class="arguement">
<input type="checkbox" id="xieyi" /> 阅读并同意
<a href="javascript:void(0)">《你问我答用户注册协议》</a>
<a href="register.html">没有账号,立即注册</a>
<div class="tips" style="color: red">
<s:property value="#error"/>
</div>
</div>
<div class="submit_btn">
<button type="submit" id="submit_btn">
立 即 登录
</button>
</div>
</form>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html>
<html> <head>
<meta charset="UTF-8"> <link rel="stylesheet" href="css/head.css" />
<link rel="stylesheet" type="text/css" href="css/login.css" />
</head> <body>
<div class="dvhead">
<div class="dvlogo"><a href="index.html">你问我答</a></div>
<div class="dvsearch">10秒钟注册账号,找到你的同学</div>
<div class="dvreg">
已有账号,立即 <a href="login.html">登录</a>
</div>
</div>
<section class="sec">
<form action="${pageContext.request.contextPath }/UserAction_login" method="post">
<div class="register-box">
<label for="username" class="username_label">
用 户 名
<input maxlength="20" name="username" type="text"
placeholder="您的用户名和登录名" />
</label>
<div class="tips">
</div>
</div>
<div class="register-box">
<label for="username" class="other_label">
密 码
<input maxlength="20" type="password" name="password"
placeholder="建议至少使用两种字符组合" />
</label>
<div class="tips"> </div>
</div>
<div class="arguement">
<input type="checkbox" id="xieyi" /> 阅读并同意
<a href="javascript:void(0)">《你问我答用户注册协议》</a>
<a href="register.html">没有账号,立即注册</a>
<div class="tips" style="color: red">
<s:property value="#error"/>
</div>
</div>
<div class="submit_btn">
<button type="submit" id="submit_btn">
立 即 登录
</button>
</div>
</form>
</section>
<script src="js/index.js" type="text/javascript" charset="utf-8"></script>
</body>
login.jsp
四.2、整合Spring与Struts
导入struts2-spring-plugin-2.5.16.jar整合包
在stuts.xml中让spring管理Action的创建
<!-- 让spring管理Action的创建 -->
<constant name="struts.objectFactory" value="spring"></constant>
在applicationContext.xml中配置web层、service层、dao层的<bean>元素
<!-- 配置userAciton -->
<bean name="userAction" class="com.Gary.web.UserAction" scope="prototype">
<!-- 注入userService -->
<property name="userService" ref="userService"></property>
</bean> <!-- 配置userService -->
<bean name="userService" class="com.Gary.service.UserService">
<!-- 注入userDao -->
<property name="userDao" ref="userDao"></property>
</bean> <!-- 配置userDao -->
<bean name="userDao" class="com.Gary.dao.UserDao">
<!-- 注入sessionFactory (用到了HibernateDaoSupport) -->
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<?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"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd"> <!-- 配置userAciton -->
<bean name="userAction" class="com.Gary.web.UserAction" scope="prototype">
<!-- 注入userService -->
<property name="userService" ref="userService"></property>
</bean> <!-- 配置userService -->
<bean name="userService" class="com.Gary.service.UserService">
<!-- 注入userDao -->
<property name="userDao" ref="userDao"></property>
</bean> <!-- 配置userDao -->
<bean name="userDao" class="com.Gary.dao.UserDao">
<!-- 注入sessionFactory (用到了HibernateDaoSupport) -->
<property name="sessionFactory" ref="sessionFactory"></property>
</bean> </beans>
applicationContext.xml
五、整合Hibernate、引入连接池并使用hibernate模板
在applicationContext.xml中整合Hibernate
<bean name="dataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="jdbcUrl" value="jdbc:mysql:///spring"></property>
<property name="driverClass" value="com.mysql.jdbc.Driver"></property>
<property name="user" value="root"></property>
<property name="password" value="123456"></property>
</bean> <!-- 配置sesisonFactory -->
<bean name="sessionFactory"
class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<!-- 配置dataSource -->
<property name="dataSource" ref="dataSource"></property>
<!-- 配置基本属性 -->
<property name="hibernateProperties">
<props>
<!-- 方言 -->
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
<!-- 生成表策略 -->
<prop key="hibernate.hbm2ddl.auto">update</prop>
<!-- 是否生成sql语句 -->
<prop key="hibernate.show_sql">true</prop>
<!-- 是否格式化sql -->
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
<!-- 读取orm元数据 -->
<property name="mappingDirectoryLocations"
value="classpath:com/Gary/domain"></property> </bean>
<?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"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd"> <bean name="dataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="jdbcUrl" value="jdbc:mysql:///spring"></property>
<property name="driverClass" value="com.mysql.jdbc.Driver"></property>
<property name="user" value="root"></property>
<property name="password" value="123456"></property>
</bean> <!-- 配置sesisonFactory -->
<bean name="sessionFactory"
class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<!-- 配置dataSource -->
<property name="dataSource" ref="dataSource"></property>
<!-- 配置基本属性 -->
<property name="hibernateProperties">
<props>
<!-- 方言 -->
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
<!-- 生成表策略 -->
<prop key="hibernate.hbm2ddl.auto">update</prop>
<!-- 是否生成sql语句 -->
<prop key="hibernate.show_sql">true</prop>
<!-- 是否格式化sql -->
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
<!-- 读取orm元数据 -->
<property name="mappingDirectoryLocations"
value="classpath:com/Gary/domain"></property> </bean> <!-- 配置userAciton -->
<bean name="userAction" class="com.Gary.web.UserAction" scope="prototype">
<!-- 注入userService -->
<property name="userService" ref="userService"></property>
</bean> <!-- 配置userService -->
<bean name="userService" class="com.Gary.service.UserService">
<!-- 注入userDao -->
<property name="userDao" ref="userDao"></property>
</bean> <!-- 配置userDao -->
<bean name="userDao" class="com.Gary.dao.UserDao">
<!-- 注入sessionFactory (用到了HibernateDaoSupport) -->
<property name="sessionFactory" ref="sessionFactory"></property>
</bean> </beans>
applicationContext.xml
在web.xml中扩大session范围【扩大session范围<filter>一定要放在启动struts上】
<!-- 扩大session范围 -->
<filter>
<filter-name>openSessionInView</filter-name>
<filter-class>org.springframework.orm.hibernate5.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>openSessionInView</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>SSH</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list> <!-- 让spring随着web项目的启动而启动 -->
<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> <!-- 扩大session范围 -->
<filter>
<filter-name>openSessionInView</filter-name>
<filter-class>org.springframework.orm.hibernate5.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>openSessionInView</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <!-- 让struts启动 -->
<filter>
<filter-name>struts</filter-name>
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> </web-app>
web.xml
六、整合事务
在applicationContext.xml中配置事务
<!-- 事务的核心管理器 -->
<bean name="transactionManager"
class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<!-- 需要sessionFactory -->
<property name="sessionFactory" ref="sessionFactory"></property>
</bean> <!-- 通知 -->
<tx:advice id="advice"
transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="*" />
</tx:attributes>
</tx:advice> <!-- 织入 -->
<aop:config>
<!-- 切入点 -->
<aop:pointcut
expression="execution(* com.Gary.service.*.*(..))" id="pc" />
<!-- 配置切面 -->
<aop:advisor advice-ref="advice" pointcut-ref="pc" />
</aop:config>
<?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"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd"> <bean name="dataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="jdbcUrl" value="jdbc:mysql:///spring"></property>
<property name="driverClass" value="com.mysql.jdbc.Driver"></property>
<property name="user" value="root"></property>
<property name="password" value="123456"></property>
</bean> <!-- 配置sesisonFactory -->
<bean name="sessionFactory"
class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<!-- 配置dataSource -->
<property name="dataSource" ref="dataSource"></property>
<!-- 配置基本属性 -->
<property name="hibernateProperties">
<props>
<!-- 方言 -->
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
<!-- 生成表策略 -->
<prop key="hibernate.hbm2ddl.auto">update</prop>
<!-- 是否生成sql语句 -->
<prop key="hibernate.show_sql">true</prop>
<!-- 是否格式化sql -->
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
<!-- 读取orm元数据 -->
<property name="mappingDirectoryLocations"
value="classpath:com/Gary/domain"></property>
</bean> <!-- 事务的核心管理器 -->
<bean name="transactionManager"
class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<!-- 需要sessionFactory -->
<property name="sessionFactory" ref="sessionFactory"></property>
</bean> <!-- 通知 -->
<tx:advice id="advice"
transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="*" />
</tx:attributes>
</tx:advice> <!-- 织入 -->
<aop:config>
<!-- 切入点 -->
<aop:pointcut
expression="execution(* com.Gary.service.*.*(..))" id="pc" />
<!-- 配置切面 -->
<aop:advisor advice-ref="advice" pointcut-ref="pc" />
</aop:config> <!-- 配置userAciton -->
<bean name="userAction" class="com.Gary.web.UserAction" scope="prototype">
<!-- 注入userService -->
<property name="userService" ref="userService"></property>
</bean> <!-- 配置userService -->
<bean name="userService" class="com.Gary.service.UserService">
<!-- 注入userDao -->
<property name="userDao" ref="userDao"></property>
</bean> <!-- 配置userDao -->
<bean name="userDao" class="com.Gary.dao.UserDao">
<!-- 注入sessionFactory (用到了HibernateDaoSupport) -->
<property name="sessionFactory" ref="sessionFactory"></property>
</bean> </beans>
applicationContext.xml
JavaWeb_(SSH)三大框架整合struts+hibernate+spring_Demo的更多相关文章
- Maven SSH三大框架整合的加载流程
<Maven精品教程视频\day02视频\03ssh配置文件加载过程.avi;> 此课程中讲 SSH三大框架整合的加载流程,还可以,初步接触的朋友可以听一听. < \day02视频\ ...
- 三大框架:Struts+Hibernate+Spring
三大框架:Struts+Hibernate+Spring Java三大框架主要用来做WEN应用. Struts主要负责表示层的显示 Spring利用它的IOC和AOP来处理控制业务(负责对数据库的操作 ...
- SSH三大框架整合案例
SSH三大框架的整合 SSH三个框架的知识点 一.Hibernate框架 1. Hibernate的核心配置文件 1.1 数据库信息.连接池配置 1.2 Hibernate信息 1.3 映射配置 ...
- SSH三大框架整合配置详解
首先,三大框架整合,肯定是要导入相当多的jar包,这是不容置疑的! 这里就不一一列举了,直接截图吧: (1) 基于配置文件的整合: 第一步:我们需要在we ...
- 关于ssh三大框架整合的碎碎念
三大框架整合,无非就是一个导jar包,修改配置文件的过程.完了就没事了. 还是有很多细节性的问题 比如在spring中写applicationContext.xml文件时不提示: 解决方法如下: 如果 ...
- SSH 三大框架整合
Spring整合web项目 在Servlet当中直接加载配置文件,获取对象 存在问题 每次请求都会创建一个Spring的工厂,这样浪费服务器资源,应该一个项目只有一个Spring的工厂. 在服务器启动 ...
- 2018.11.11 Java的 三大框架:Struts+Hibernate+Spring
·定义:Java三大框架主要用来做WEN应用.Struts主要负责表示层的显示: Spring利用它的IOC和AOP来处理控制业务(负责对数据库的操作): Hibernate主要是数据持久化到数据库. ...
- SSH三大框架整合配置详细步骤(3)
5 配置Spring2.5 5.1 基础配置 1) 导入spring包.下载spring-framework-2.5.6并解压后,在spring-framework-2.5.6" ...
- JAVAEE——SSH三大框架整合(spring+struts2+hibernate)
一.整合原理 二.导包(41个) 1.hibernate (1)hibernate/lib/required (2)hibernate/lib/jpa | java persist api java的 ...
随机推荐
- Tomcat的架构
Tomcat 7.0---Servlet API 3.0---JSP API 2.2---JDK 1.6 一个Tomcat实例,或者服务器(server),是Tomcat容器层次结构中的顶级组件. 只 ...
- github骚操作
限制搜索 in关键词限制搜索范围 命令 说明 xxx in:name 项目名包含xxx的 xxx in:description 项目描述包含xxx的 xxx in:readme 项目的readme文件 ...
- Rikka with Competition hdu 6095
签到题目,排序然后按序清理掉一定会输的结果就可以. ac代码: #include <iostream> #include <cstdio> #include <cstri ...
- C# 读取本地图片
/// <summary> /// 通过FileStream 来打开文件,这样就可以实现不锁定Image文件,到时可以让多用户同时访问Image文件 /// </summary> ...
- hexo发布后样式丢失
修改配置中url路径,和root,问题解决.
- HTML and CSS basis
classes 和 IDs 的不同 class 选择器用于描述一组元素的样式,class 选择器有别于id选择器,class可以在多个元素中使用. HTML 元素 elements 从开始标签(sta ...
- SqlServer 附加数据库出错
方法一 找到要添加数据库的.mdf文件,点击右键,选择属性 在属性页面点击安全,选择Authenticated Users,单击编辑 Authenticated Users权限中选择完全控制,点击确定 ...
- Spring Cloud(九)高可用的分布式配置中心 Spring Cloud Config 集成 Eureka 服务
上一篇文章,讲了SpringCloudConfig 集成Git仓库,这一篇我们讲一下SpringCloudConfig 配和 Eureka 注册中心一起使用 在分布式系统中,由于服务数量巨多,为了方便 ...
- 阿里十年架构师告诉你Spring Boot与Spring Cloud是什么关系
SpringBoot先于Spring Cloud问世.SpringBoot相当于脚手架,借助他可以快速搭建房子,它本身不具备任何功能属性,值是普通房间,没有其他任何功能. 什么是Spring Boot ...
- (备忘)Nodepad++常用快捷键
Ctrl-H 打开Find / Replace 对话框 Ctrl-D 复制当前行 Ctrl-L 删除当前行 Ctrl-T 上下行交换 F3 找下一个 Shift-F3 找上一个 Ctrl-Shift- ...