Struts2+Spring+Hibernate搭建全解!
作者:施杨(施杨's Think out)
出处:http://shiyangxt.cnblogs.com
Struts2+Spring+Hibernate是J2EE的最新流行框架。本篇是我搭建这个框架的经验总结,有很多人搭建这个框架总会遇到
大大小小的问题,网上也没有什么行之有效的方案或成体系的介绍,所以我就决定总结一下我的搭建过程。给一些搭
建尚存问题的朋友提供帮助。
我用这个框架,实现的是基本的CRUD功能的一个雇员管理系统,本来打算丰富一下功能,但是一直没能抽出空去搞。
目前版本暂定为1.0,除了CRUD外还配置了表单验证框架JSValidation。功能都能很顺利的实现。
现在分享部分源码,来说明一些注意事项。
以下是部分搭建过程及源码:
1.先组合实现Hibernate3.2+Spring2.5支持,删除hibernate.cfg.xml文件,修改applicationContext.xml文件的内容,增加SessionFactory和dataSource的设置。
2.通过MyEclipse的向导方式,生成POJO类和对应的映射文件。
3.修改applicationContext.xml文件中<property name="mappingResources">元素的内容。
4.编写DAO接口和实现类。
5.修改applicationContext.xml文件,增加对Dao实现类的配置。
6.组合Struts2和Spring2.5,修改web.xml文件,增加struts2的所需要的过滤器配置。
7.增加struts2相应类库,增加struts2与spring的配置jar包。
8.拷贝struts.xml文件到src根目录下,再修改struts.xml文件,进行常量配置。
9.修改web.xml文件,配置Spring监听器,和上下文变量。并增加OpenSessionInViewFilter的设置。
10.写入action类。
11.配置struts.xml文件。
12.修改applicationContext.xml
13.编写Jsp文件。
14.加载运行项目。
下面是关键文件的源码:
struts.xml源码:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<!-- struts2委托spring管理 -->
<constant name="struts.objectFactory" value="spring"/>
<!-- /crm/emp/add.action -->
<package name="crm_employee" extends="struts-default" namespace="/emp">
<action name="add" class="addBean" method="add">
<result>add.action</result>
<result>/emp/add_suc.jsp</result>
</action>
<action name="list" class="listBean" method="list">
<result>/emp/list.jsp</result>
</action>
<action name="delete" class="deleteBean" method="delete">
<result>delete.action</result>
<result>/emp/delete_suc.jsp</result>
</action>
<action name="update" class="updateBean" method="update">
<result>update.action</result>
<result>/emp/edit_suc.jsp</result>
</action>
<action name="edit" class="editBean" method="edit">
<result>/emp/edit.jsp</result>
</action>
<!-- Add actions here -->
</package>
</struts>
web.xml源码:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- 配置spring的监听器 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext*.xml</param-value>
</context-param>
<!-- 开启监听 -->
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<!-- 配置OpenSessionInViewFilter,必须在struts2监听之前 -->
<filter>
<filter-name>lazyLoadingFilter</filter-name>
<filter-class>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
</filter-class>
</filter>
<!-- 设置监听加载上下文 -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>lazyLoadingFilter</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
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: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-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<!-- 配置Hibernate支持 -->
<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/tables">
</property>
<property name="username" value="root"></property>
<property name="password" value="hicc"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/sy/crm/model/Employee.hbm.xml</value>
</list>
</property>
</bean>
<bean id="employeeDao"
class="com.sy.crm.dao.hibernate.EmployeeDaoHibernate">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="employeeManager"
class="com.sy.crm.service.impl.EmployeeManagerImpl">
<property name="employeeDao">
<ref bean="employeeDao" />
</property>
</bean>
<bean id="addBean" class="com.sy.crm.action.EmployeeAction" scope="prototype">
<property name="employeeManager">
<ref bean="employeeManager" />
</property>
</bean>
<bean id="listBean" class="com.sy.crm.action.EmployeeAction" scope="prototype">
<property name="employeeManager">
<ref bean="employeeManager" />
</property>
</bean>
<bean id="deleteBean" class="com.sy.crm.action.EmployeeAction" scope="prototype">
<property name="employeeManager">
<ref bean="employeeManager" />
</property>
</bean>
<bean id="updateBean" class="com.sy.crm.action.EmployeeAction" scope="prototype">
<property name="employeeManager">
<ref bean="employeeManager" />
</property>
</bean>
<bean id="editBean" class="com.sy.crm.action.EmployeeAction" scope="prototype">
<property name="employeeManager">
<ref bean="employeeManager" />
</property>
</bean>
<!-- 事务管理器 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
<!-- 配置事务特性,配置add,delete,update开始的方法,事务传播特性为required -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>
<!-- 配置那些类的方法进行事务管理,当前com.sy.crm.service包中的子包,
类中所有方法需要,还需要参考tx:advice的设置 -->
<aop:config>
<aop:pointcut id="allManagerMethod" expression="execution(*
com.sy.crm.service.*.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="allManagerMethod"/>
</aop:config>
</beans>
add.jsp源码:
<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>add page</title>
<script language="JavaScript" src="validation-framework.js"></script>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
</head>
<body>
<center>
<h3>雇员注册:</h3><br>
<h4><a href="../emp/list.action">查看所有雇员</a></h4>
<div id="error" style="color:blue; font-weight:bold;"></div>
<s:form action="add" method="post" onsubmit="return doValidate('form')" name="form" id="form">
<s:textfield name="employee.name" label="姓名" id="name"/>
<s:textfield name="employee.address" label="地址"/>
<s:textfield name="employee.phone" label="电话"/>
<s:submit value="员工注册"/>
</s:form>
</center>
</body>
</html>
list.jsp源码:
<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>list employee page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<style type="text/css">
table {
border: 1px solid black;
border-collapse: collapse;
}
table thead tr th {
border: 1px solid black;
padding: 3px;
background-color: #cccccc;
}
table tbody tr td {
border: 1px solid black;
padding: 3px;
}
</style>
</head>
<body>
<center>
<h3>
雇员管理:
</h3>
<br>
<h4>
<a href="../emp/add.jsp">员工注册</a>
</h4>
<s:form action="delete" theme="simple">
<table>
<thead>
<tr>
<th>
选择
</th>
<th>
编号
</th>
<th>
姓名
</th>
<th>
电话
</th>
<th>
地址
</th>
<th>
操作
</th>
</tr>
</thead>
<tbody>
<s:iterator value="employees">
<tr>
<td>
<input type="checkbox" name="id"
value='<s:property value="id" />' />
</td>
<td>
<s:property value="id" />
</td>
<td>
<s:property value="name" />
</td>
<td>
<s:property value="phone" />
</td>
<td>
<s:property value="address" />
</td>
<td>
<a
href='<s:url action="edit"><s:param name="id" value="id" /></s:url>'>
修改 </a>
<a
href='<s:url action="delete"><s:param name="id" value="id" /></s:url>'>
删除 </a>
</td>
</tr>
</s:iterator>
</tbody>
</table>
<s:submit value="delete" />
</s:form>
</center>
</body>
</html>
显示界面如图:
下面是项目的构图:
第一点注意的是,搭建出项目,一定会报错,因为Spring 2.5 AOP Libraries中的asm的三个jar包会和
Hibernate 3.2 Core Libraries中的asm的jar包中的某些类中有冲突。所以一定要删除Spring中的三个asm的jar包。
第二点要注意的是,struts2的配置包的导入,需要的是5个jar包分别是:
struts2-core-2.0.11.2.jar
freemarker-2.3.8.jar
ognl-2.6.11.jar
xwork-2.05.jar
commons-logging-1.0.4.jar
struts2+spring配置包:struts2-spring-plugin-2.0.11.2.jar
网上有些还说需要把4个spring的包拷到lib下,我是拷了但是,并不确定这样做是否有必要。
总之是正常运行了。
所以也就没想太多。如果有的朋友运行不了,可以考虑把这4个需要的包写上来。
好了就说这么多吧,有疑问的朋友可以留言。我会尽量答复。
施杨出品!!!
更多学习资料:http://gz.itcast.cn/
出处:http://shiyangxt.cnblogs.com
Struts2+Spring+Hibernate是J2EE的最新流行框架。本篇是我搭建这个框架的经验总结,有很多人搭建这个框架总会遇到
大大小小的问题,网上也没有什么行之有效的方案或成体系的介绍,所以我就决定总结一下我的搭建过程。给一些搭
建尚存问题的朋友提供帮助。
我用这个框架,实现的是基本的CRUD功能的一个雇员管理系统,本来打算丰富一下功能,但是一直没能抽出空去搞。
目前版本暂定为1.0,除了CRUD外还配置了表单验证框架JSValidation。功能都能很顺利的实现。
现在分享部分源码,来说明一些注意事项。
以下是部分搭建过程及源码:
1.先组合实现Hibernate3.2+Spring2.5支持,删除hibernate.cfg.xml文件,修改applicationContext.xml文件的内容,增加SessionFactory和dataSource的设置。
2.通过MyEclipse的向导方式,生成POJO类和对应的映射文件。
3.修改applicationContext.xml文件中<property name="mappingResources">元素的内容。
4.编写DAO接口和实现类。
5.修改applicationContext.xml文件,增加对Dao实现类的配置。
6.组合Struts2和Spring2.5,修改web.xml文件,增加struts2的所需要的过滤器配置。
7.增加struts2相应类库,增加struts2与spring的配置jar包。
8.拷贝struts.xml文件到src根目录下,再修改struts.xml文件,进行常量配置。
9.修改web.xml文件,配置Spring监听器,和上下文变量。并增加OpenSessionInViewFilter的设置。
10.写入action类。
11.配置struts.xml文件。
12.修改applicationContext.xml
13.编写Jsp文件。
14.加载运行项目。
下面是关键文件的源码:
struts.xml源码:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<!-- struts2委托spring管理 -->
<constant name="struts.objectFactory" value="spring"/>
<!-- /crm/emp/add.action -->
<package name="crm_employee" extends="struts-default" namespace="/emp">
<action name="add" class="addBean" method="add">
<result>add.action</result>
<result>/emp/add_suc.jsp</result>
</action>
<action name="list" class="listBean" method="list">
<result>/emp/list.jsp</result>
</action>
<action name="delete" class="deleteBean" method="delete">
<result>delete.action</result>
<result>/emp/delete_suc.jsp</result>
</action>
<action name="update" class="updateBean" method="update">
<result>update.action</result>
<result>/emp/edit_suc.jsp</result>
</action>
<action name="edit" class="editBean" method="edit">
<result>/emp/edit.jsp</result>
</action>
<!-- Add actions here -->
</package>
</struts>
web.xml源码:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- 配置spring的监听器 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext*.xml</param-value>
</context-param>
<!-- 开启监听 -->
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<!-- 配置OpenSessionInViewFilter,必须在struts2监听之前 -->
<filter>
<filter-name>lazyLoadingFilter</filter-name>
<filter-class>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
</filter-class>
</filter>
<!-- 设置监听加载上下文 -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>lazyLoadingFilter</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
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: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-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<!-- 配置Hibernate支持 -->
<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/tables">
</property>
<property name="username" value="root"></property>
<property name="password" value="hicc"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/sy/crm/model/Employee.hbm.xml</value>
</list>
</property>
</bean>
<bean id="employeeDao"
class="com.sy.crm.dao.hibernate.EmployeeDaoHibernate">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="employeeManager"
class="com.sy.crm.service.impl.EmployeeManagerImpl">
<property name="employeeDao">
<ref bean="employeeDao" />
</property>
</bean>
<bean id="addBean" class="com.sy.crm.action.EmployeeAction" scope="prototype">
<property name="employeeManager">
<ref bean="employeeManager" />
</property>
</bean>
<bean id="listBean" class="com.sy.crm.action.EmployeeAction" scope="prototype">
<property name="employeeManager">
<ref bean="employeeManager" />
</property>
</bean>
<bean id="deleteBean" class="com.sy.crm.action.EmployeeAction" scope="prototype">
<property name="employeeManager">
<ref bean="employeeManager" />
</property>
</bean>
<bean id="updateBean" class="com.sy.crm.action.EmployeeAction" scope="prototype">
<property name="employeeManager">
<ref bean="employeeManager" />
</property>
</bean>
<bean id="editBean" class="com.sy.crm.action.EmployeeAction" scope="prototype">
<property name="employeeManager">
<ref bean="employeeManager" />
</property>
</bean>
<!-- 事务管理器 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
<!-- 配置事务特性,配置add,delete,update开始的方法,事务传播特性为required -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>
<!-- 配置那些类的方法进行事务管理,当前com.sy.crm.service包中的子包,
类中所有方法需要,还需要参考tx:advice的设置 -->
<aop:config>
<aop:pointcut id="allManagerMethod" expression="execution(*
com.sy.crm.service.*.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="allManagerMethod"/>
</aop:config>
</beans>
add.jsp源码:
<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>add page</title>
<script language="JavaScript" src="validation-framework.js"></script>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
</head>
<body>
<center>
<h3>雇员注册:</h3><br>
<h4><a href="../emp/list.action">查看所有雇员</a></h4>
<div id="error" style="color:blue; font-weight:bold;"></div>
<s:form action="add" method="post" onsubmit="return doValidate('form')" name="form" id="form">
<s:textfield name="employee.name" label="姓名" id="name"/>
<s:textfield name="employee.address" label="地址"/>
<s:textfield name="employee.phone" label="电话"/>
<s:submit value="员工注册"/>
</s:form>
</center>
</body>
</html>
list.jsp源码:
<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>list employee page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<style type="text/css">
table {
border: 1px solid black;
border-collapse: collapse;
}
table thead tr th {
border: 1px solid black;
padding: 3px;
background-color: #cccccc;
}
table tbody tr td {
border: 1px solid black;
padding: 3px;
}
</style>
</head>
<body>
<center>
<h3>
雇员管理:
</h3>
<br>
<h4>
<a href="../emp/add.jsp">员工注册</a>
</h4>
<s:form action="delete" theme="simple">
<table>
<thead>
<tr>
<th>
选择
</th>
<th>
编号
</th>
<th>
姓名
</th>
<th>
电话
</th>
<th>
地址
</th>
<th>
操作
</th>
</tr>
</thead>
<tbody>
<s:iterator value="employees">
<tr>
<td>
<input type="checkbox" name="id"
value='<s:property value="id" />' />
</td>
<td>
<s:property value="id" />
</td>
<td>
<s:property value="name" />
</td>
<td>
<s:property value="phone" />
</td>
<td>
<s:property value="address" />
</td>
<td>
<a
href='<s:url action="edit"><s:param name="id" value="id" /></s:url>'>
修改 </a>
<a
href='<s:url action="delete"><s:param name="id" value="id" /></s:url>'>
删除 </a>
</td>
</tr>
</s:iterator>
</tbody>
</table>
<s:submit value="delete" />
</s:form>
</center>
</body>
</html>
显示界面如图:
下面是项目的构图:
第一点注意的是,搭建出项目,一定会报错,因为Spring 2.5 AOP Libraries中的asm的三个jar包会和
Hibernate 3.2 Core Libraries中的asm的jar包中的某些类中有冲突。所以一定要删除Spring中的三个asm的jar包。
第二点要注意的是,struts2的配置包的导入,需要的是5个jar包分别是:
struts2-core-2.0.11.2.jar
freemarker-2.3.8.jar
ognl-2.6.11.jar
xwork-2.05.jar
commons-logging-1.0.4.jar
struts2+spring配置包:struts2-spring-plugin-2.0.11.2.jar
网上有些还说需要把4个spring的包拷到lib下,我是拷了但是,并不确定这样做是否有必要。
总之是正常运行了。
所以也就没想太多。如果有的朋友运行不了,可以考虑把这4个需要的包写上来。
好了就说这么多吧,有疑问的朋友可以留言。我会尽量答复。
施杨出品!!!
更多学习资料:http://gz.itcast.cn/
相关推荐
### Struts2+Spring+Hibernate框架搭建全解 在Java Web开发领域,Struts2、Spring与Hibernate(通常被简称为SSH)组合成一个非常流行的轻量级开发框架。这三者结合能够很好地解决Web应用中的业务逻辑处理、数据持久...
【标题】"Struts2+Spring+Hibernate搭建全解!" 【描述】在现代Web开发中,企业级应用经常采用MVC(Model-View-Controller)架构模式来组织代码,提高可维护性和可扩展性。Struts2、Spring和Hibernate是Java Web...
### SSH框架搭建全解 SSH框架,即Struts+Spring+Hibernate框架的组合,是Java Web开发中的一个经典且流行的组合。本文将详细介绍如何搭建这一框架,并通过具体步骤和示例代码来帮助初学者理解整个过程。 #### 一、...
基于Maxwell设计的经典280W 4025RPM高效率科尔摩根12极39槽TBM无框力矩电机:生产与学习双重应用案例,基于Maxwell设计的经典280W高转速科尔摩根TBM无框力矩电机:7615系列案例解析与应用实践,基于maxwwell设计的经典280W,4025RPM 内转子 科尔摩根 12极39槽 TBM无框力矩电机,7615系列。 该案例可用于生产,或者学习用,(157) ,maxwell设计; 280W; 4025RPM内转子; 科尔摩根; 12极39槽TBM无框力矩电机; 7615系列; 生产/学习用。,基于Maxwell设计,高功率280W 12极39槽TBM无框力矩电机:生产与学习双用途案例
基于碳交易的微网优化模型的Matlab设计与实现策略分析,基于碳交易的微网优化模型的Matlab设计与实现探讨,考虑碳交易的微网优化模型matlab ,考虑碳交易; 微网优化模型; MATLAB;,基于Matlab的碳交易微网优化模型研究
二级2025模拟试题(答案版)
OpenCV是一个功能强大的计算机视觉库,它提供了多种工具和算法来处理图像和视频数据。在C++中,OpenCV可以用于实现基础的人脸识别功能,包括从摄像头、图片和视频中识别人脸,以及通过PCA(主成分分析)提取图像轮廓。以下是对本资源大体的介绍: 1. 从摄像头中识别人脸:通过使用OpenCV的Haar特征分类器,我们可以实时从摄像头捕获的视频流中检测人脸。这个过程涉及到将视频帧转换为灰度图像,然后使用预训练的Haar级联分类器来识别人脸区域。 2. 从视频中识别出所有人脸和人眼:在视频流中,除了检测人脸,我们还可以进一步识别人眼。这通常涉及到使用额外的Haar级联分类器来定位人眼区域,从而实现对人脸特征的更细致分析。 3. 从图片中检测出人脸:对于静态图片,OpenCV同样能够检测人脸。通过加载图片,转换为灰度图,然后应用Haar级联分类器,我们可以在图片中标记出人脸的位置。 4. PCA提取图像轮廓:PCA是一种统计方法,用于分析和解释数据中的模式。在图像处理中,PCA可以用来提取图像的主要轮廓特征,这对于人脸识别技术中的面部特征提取尤
麻雀搜索算法(SSA)自适应t分布改进版:卓越性能与优化代码注释,适合深度学习。,自适应t分布改进麻雀搜索算法(TSSA)——卓越的学习样本,优化效果出众,麻雀搜索算法(SSA)改进——采用自适应t分布改进麻雀位置(TSSA),优化后明显要优于基础SSA(代码基本每一步都有注释,代码质量极高,非常适合学习) ,TSSA(自适应t分布麻雀位置算法);注释详尽;高质量代码;适合学习;算法改进结果优异;TSSA相比基础SSA。,自适应T分布优化麻雀搜索算法:代码详解与学习首选(TSSA改进版)
锂电池主动均衡Simulink仿真研究:多种均衡策略与电路架构的深度探讨,锂电池主动均衡与多种均衡策略的Simulink仿真研究:buckboost拓扑及多层次电路分析,锂电池主动均衡simulink仿真 四节电池 基于buckboost(升降压)拓扑 (还有传统电感均衡+开关电容均衡+双向反激均衡+双层准谐振均衡+环形均衡器+cuk+耦合电感)被动均衡电阻式均衡 、分层架构式均衡以及分层式电路均衡,多层次电路,充放电。 ,核心关键词: 锂电池; 主动均衡; Simulink仿真; 四节电池; BuckBoost拓扑; 传统电感均衡; 开关电容均衡; 双向反激均衡; 双层准谐振均衡; 环形均衡器; CUK均衡; 耦合电感均衡; 被动均衡; 电阻式均衡; 分层架构式均衡; 多层次电路; 充放电。,锂电池均衡策略研究:Simulink仿真下的多拓扑主动与被动均衡技术
S7-1500和分布式外围系统ET200MP模块数据
内置式永磁同步电机无位置传感器模型:基于滑膜观测器和MTPA技术的深度探究,内置式永磁同步电机基于滑膜观测器和MTPA的无位置传感器模型研究,基于滑膜观测器和MTPA的内置式永磁同步电机无位置传感器模型 ,基于滑膜观测器;MTPA;内置式永磁同步电机;无位置传感器模型,基于滑膜观测与MTPA算法的永磁同步电机无位置传感器模型
centos7操作系统下安装docker,及docker常用命令、在docker中运行nginx示例,包括 1.设置yum的仓库 2.安装 Docker Engine-Community 3.docker使用 4.查看docker进程是否启动成功 5.docker常用命令及nginx示例 6.常见问题
给曙光服务器安装windows2012r2时候找不到磁盘,问厂家工程师要的raid卡驱动,内含主流大多数品牌raid卡驱动
数学建模相关主题资源2
西门子四轴卧式加工中心后处理系统:828D至840D支持,四轴联动制造解决方案,图档处理与试看程序一应俱全。,西门子四轴卧加后处理系统:支持828D至840D系统,四轴联动高精度制造解决方案,西门子四轴卧加后处理,支持828D~840D系统,支持四轴联动,可制制,看清楚联系,可提供图档处理试看程序 ,核心关键词:西门子四轴卧加后处理; 828D~840D系统支持; 四轴联动; 制程; 联系; 图档处理试看程序。,西门子四轴卧加后处理程序,支持多种系统与四轴联动
MATLAB下基于列约束生成法CCG的两阶段鲁棒优化问题求解入门指南:算法验证与经典文献参考,MATLAB下基于列约束生成法CCG的两阶段鲁棒优化问题求解入门指南:算法验证与文献参考,MATLAB代码:基于列约束生成法CCG的两阶段问题求解 关键词:两阶段鲁棒 列约束生成法 CCG算法 参考文档:《Solving two-stage robust optimization problems using a column-and-constraint generation method》 仿真平台:MATLAB YALMIP+CPLEX 主要内容:代码构建了两阶段鲁棒优化模型,并用文档中的相对简单的算例,进行CCG算法的验证,此篇文献是CCG算法或者列约束生成算法的入门级文献,其经典程度不言而喻,几乎每个搞CCG的两阶段鲁棒的人都绕不过此篇文献 ,两阶段鲁棒;列约束生成法;CCG算法;MATLAB;YALMIP+CPLEX;入门级文献。,MATLAB代码实现:基于两阶段鲁棒与列约束生成法CCG的算法验证研究
“生热研究的全面解读:探究参数已配置的Comsol模型中的18650圆柱锂电池表现”,探究已配置参数的COMSOL模型下的锂电池生热现象:18650圆柱锂电池模拟分析,出一个18650圆柱锂电池comsol模型 参数已配置,生热研究 ,出模型; 18650圆柱锂电池; comsol模型; 参数配置; 生热研究,构建18650电池的COMSOL热研究模型
移动端多端运行的知识付费管理系统源码,TP6+Layui+MySQL后端支持,功能丰富,涵盖直播、点播、管理全功能及礼物互动,基于UniApp跨平台开发的移动端知识付费管理系统源码:多端互通、全功能齐备、后端采用TP6与PHP及Layui前端,搭载MySQL数据库与直播、点播、管理、礼物等功能的强大整合。,知识付费管理系统源码,移动端uniApp开发,app h5 小程序一套代码多端运行,后端php(tp6)+layui+MySQL,功能齐全,直播,点播,管理,礼物等等功能应有尽有 ,知识付费;管理系统源码;移动端uniApp开发;多端运行;后端php(tp6);layui;MySQL;直播点播;管理功能;礼物功能,知识付费管理平台:全功能多端运行系统源码(PHP+Layui+MySQL)
基于Python+Django+MySQL的个性化图书推荐系统:协同过滤推荐,智能部署,用户定制功能,基于Python+Django+MySQL的个性化图书推荐系统:协同过滤推荐,智能部署,用户定制功能,Python+Django+Mysql个性化图书推荐系统 图书在线推荐系统 基于用户、项目、内容的协同过滤推荐算法。 帮远程安装部署 一、项目简介 1、开发工具和实现技术 Python3.8,Django4,mysql8,navicat数据库管理工具,html页面,javascript脚本,jquery脚本,bootstrap前端框架,layer弹窗组件、webuploader文件上传组件等。 2、项目功能 前台用户包含:注册、登录、注销、浏览图书、搜索图书、信息修改、密码修改、兴趣喜好标签、图书评分、图书收藏、图书评论、热点推荐、个性化推荐图书等功能; 后台管理员包含:用户管理、图书管理、图书类型管理、评分管理、收藏管理、评论管理、兴趣喜好标签管理、权限管理等。 个性化推荐功能: 无论是否登录,在前台首页展示热点推荐(根据图书被收藏数量降序推荐)。 登录用户,在前台首页展示个性化推荐