本博文使用struts2,hibernate,spring技术整合Web项目,同时分层封装代码,包含model层,DAO层,Service层,Action层。

在整合hibernate时使用annotation注释进行数据库的映射,整合spring时使用annotation进行IOC注入。

最后在DAO层中继承HibernateDaoSupport来编写代码。

首先看一下项目的目录:

需要的类库:

以person为例:

model层:

  1. package com.hwadee.tradeUnion.model;
  2.  
  3. import java.util.Date;
  4. import java.util.HashSet;
  5. import java.util.Set;
  6.  
  7. import javax.persistence.CascadeType;
  8. import javax.persistence.Column;
  9. import javax.persistence.Entity;
  10. import javax.persistence.FetchType;
  11. import javax.persistence.GeneratedValue;
  12. import javax.persistence.Id;
  13. import javax.persistence.JoinColumn;
  14. import javax.persistence.OneToMany;
  15. import javax.persistence.OneToOne;
  16.  
  17. /**
  18. * Person entity. @author MyEclipse Persistence Tools
  19. */
  20. @Entity
  21. public class Person implements java.io.Serializable {
  22.  
  23. /**
  24. *
  25. */
  26. private static final long serialVersionUID = 1L;
  27. // Fields
  28.  
  29. private int id;
  30. private String name;
  31. private String sex;
  32. private String nationality;
  33. private String area;
  34. private Date birthday;
  35. private String education;
  36. private String polity;
  37. private String company;
  38. private String idCard;
  39. private String phone;
  40.  
  41. //------------------------------------------
  42. private Set<PersonApply> personApplys = new HashSet<PersonApply>();
  43. private Set<Honour> Honours = new HashSet<Honour>();
  44. private Death death;
  45.  
  46. // Property accessors
  47. @Id
  48. @GeneratedValue
  49. public int getId() {
  50. return this.id;
  51. }
  52.  
  53. public void setId(int id) {
  54. this.id = id;
  55. }
  56.  
  57. //-------------------------------------------------
  58. @OneToMany(fetch=FetchType.EAGER,cascade={CascadeType.ALL})
  59. @JoinColumn(name="personId")
  60. public Set<PersonApply> getPersonApplys() {
  61. return personApplys;
  62. }
  63.  
  64. public void setPersonApplys(Set<PersonApply> personApplys) {
  65. this.personApplys = personApplys;
  66. }
  67.  
  68. @OneToMany(fetch=FetchType.EAGER,cascade={CascadeType.ALL})
  69. @JoinColumn(name="personId")
  70. public Set<Honour> getHonours() {
  71. return Honours;
  72. }
  73.  
  74. public void setHonours(Set<Honour> honours) {
  75. Honours = honours;
  76. }
  77.  
  78. @OneToOne
  79. @JoinColumn(name="deathId")
  80. public Death getDeath() {
  81. return death;
  82. }
  83.  
  84. public void setDeath(Death death) {
  85. this.death = death;
  86. }
  87.  
  88. //------------------------------------------------------
  89.  
  90. @Column(length = 30)
  91. public String getName() {
  92. return this.name;
  93. }
  94.  
  95. public void setName(String name) {
  96. this.name = name;
  97. }
  98.  
  99. @Column(length = 10)
  100. public String getSex() {
  101. return this.sex;
  102. }
  103.  
  104. public void setSex(String sex) {
  105. this.sex = sex;
  106. }
  107.  
  108. @Column( length = 10)
  109. public String getNationality() {
  110. return this.nationality;
  111. }
  112.  
  113. public void setNationality(String nationality) {
  114. this.nationality = nationality;
  115. }
  116.  
  117. @Column( length = 50)
  118. public String getArea() {
  119. return this.area;
  120. }
  121.  
  122. public void setArea(String area) {
  123. this.area = area;
  124. }
  125.  
  126. public Date getBirthday() {
  127. return this.birthday;
  128. }
  129.  
  130. public void setBirthday(Date birthday) {
  131. this.birthday = birthday;
  132. }
  133.  
  134. @Column( length = 10)
  135. public String getEducation() {
  136. return this.education;
  137. }
  138.  
  139. public void setEducation(String education) {
  140. this.education = education;
  141. }
  142.  
  143. @Column(length = 10)
  144. public String getPolity() {
  145. return this.polity;
  146. }
  147.  
  148. public void setPolity(String polity) {
  149. this.polity = polity;
  150. }
  151.  
  152. @Column( length = 30)
  153. public String getCompany() {
  154. return this.company;
  155. }
  156.  
  157. public void setCompany(String company) {
  158. this.company = company;
  159. }
  160.  
  161. @Column(length = 18)
  162. public String getIdCard() {
  163. return this.idCard;
  164. }
  165.  
  166. public void setIdCard(String idCard) {
  167. this.idCard = idCard;
  168. }
  169.  
  170. @Column(length = 11)
  171. public String getPhone() {
  172. return this.phone;
  173. }
  174.  
  175. public void setPhone(String phone) {
  176. this.phone = phone;
  177. }
  178.  
  179. }

DAO层:

  1. package com.hwadee.tradeUnion.dao;
  2.  
  3. import java.util.List;
  4. import org.hibernate.LockMode;
  5. import org.hibernate.SessionFactory;
  6. import org.slf4j.Logger;
  7. import org.slf4j.LoggerFactory;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.context.ApplicationContext;
  10. import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
  11. import org.springframework.stereotype.Component;
  12.  
  13. import com.hwadee.tradeUnion.model.Person;
  14.  
  15. @Component
  16. public class PersonDAO extends HibernateDaoSupport {
  17. private static final Logger log = LoggerFactory.getLogger(PersonDAO.class);
  18. // property constants
  19. public static final String NAME = "name";
  20. public static final String SEX = "sex";
  21. public static final String NATIONALITY = "nationality";
  22. public static final String AREA = "area";
  23. public static final String EDUCATION = "education";
  24. public static final String POLITY = "polity";
  25. public static final String COMPANY = "company";
  26. public static final String ID_CARD = "idCard";
  27. public static final String PHONE = "phone";
  28.  
  29. protected void initDao() {
  30. // do nothing
  31. }
  32.  
  33. //--------注入spring配置的sessionFactory
  34. @Autowired
  35. public void setMySessionFactory(SessionFactory sessionFactory){
  36. super.setSessionFactory(sessionFactory);
  37. }
  38.  
  39. public void save(Person transientInstance) {
  40. log.debug("saving Person instance");
  41. try {
  42. getHibernateTemplate().save(transientInstance);
  43. log.debug("save successful");
  44. } catch (RuntimeException re) {
  45. log.error("save failed", re);
  46. throw re;
  47. }
  48. }
  49.  
  50. public void delete(Person persistentInstance) {
  51. log.debug("deleting Person instance");
  52. try {
  53. getHibernateTemplate().delete(persistentInstance);
  54. log.debug("delete successful");
  55. } catch (RuntimeException re) {
  56. log.error("delete failed", re);
  57. throw re;
  58. }
  59. }
  60.  
  61. public void deleteById(int id){
  62.  
  63. Person temp=this.findById(id);
  64. this.delete(temp);
  65.  
  66. }
  67.  
  68. public void update(Person temp){
  69.  
  70. getHibernateTemplate().update(temp);
  71.  
  72. }
  73.  
  74. public Person findById(int id) {
  75. log.debug("getting Person instance with id: " + id);
  76. try {
  77. Person instance = (Person) getHibernateTemplate().get(
  78. Person.class, id);
  79. return instance;
  80. } catch (RuntimeException re) {
  81. log.error("get failed", re);
  82. throw re;
  83. }
  84. }
  85.  
  86. public List findByExample(Person instance) {
  87. log.debug("finding Person instance by example");
  88. try {
  89. List results = getHibernateTemplate().findByExample(instance);
  90. log.debug("find by example successful, result size: "
  91. + results.size());
  92. return results;
  93. } catch (RuntimeException re) {
  94. log.error("find by example failed", re);
  95. throw re;
  96. }
  97. }
  98.  
  99. public List findByProperty(String propertyName, Object value) {
  100. log.debug("finding Person instance with property: " + propertyName
  101. + ", value: " + value);
  102. try {
  103. String queryString = "from Person as model where model."
  104. + propertyName + "= ?";
  105. return getHibernateTemplate().find(queryString, value);
  106. } catch (RuntimeException re) {
  107. log.error("find by property name failed", re);
  108. throw re;
  109. }
  110. }
  111.  
  112. public List findByName(Object name) {
  113. return findByProperty(NAME, name);
  114. }
  115.  
  116. public List findBySex(Object sex) {
  117. return findByProperty(SEX, sex);
  118. }
  119.  
  120. public List findByNationality(Object nationality) {
  121. return findByProperty(NATIONALITY, nationality);
  122. }
  123.  
  124. public List findByArea(Object area) {
  125. return findByProperty(AREA, area);
  126. }
  127.  
  128. public List findByEducation(Object education) {
  129. return findByProperty(EDUCATION, education);
  130. }
  131.  
  132. public List findByPolity(Object polity) {
  133. return findByProperty(POLITY, polity);
  134. }
  135.  
  136. public List findByCompany(Object company) {
  137. return findByProperty(COMPANY, company);
  138. }
  139.  
  140. public List findByIdCard(Object idCard) {
  141. return findByProperty(ID_CARD, idCard);
  142. }
  143.  
  144. public List findByPhone(Object phone) {
  145. return findByProperty(PHONE, phone);
  146. }
  147.  
  148. public List findAll() {
  149. log.debug("finding all Person instances");
  150. try {
  151. String queryString = "from Person";
  152. return getHibernateTemplate().find(queryString);
  153. } catch (RuntimeException re) {
  154. log.error("find all failed", re);
  155. throw re;
  156. }
  157. }
  158.  
  159. public Person merge(Person detachedInstance) {
  160. log.debug("merging Person instance");
  161. try {
  162. Person result = (Person) getHibernateTemplate().merge(
  163. detachedInstance);
  164. log.debug("merge successful");
  165. return result;
  166. } catch (RuntimeException re) {
  167. log.error("merge failed", re);
  168. throw re;
  169. }
  170. }
  171.  
  172. public void attachDirty(Person instance) {
  173. log.debug("attaching dirty Person instance");
  174. try {
  175. getHibernateTemplate().saveOrUpdate(instance);
  176. log.debug("attach successful");
  177. } catch (RuntimeException re) {
  178. log.error("attach failed", re);
  179. throw re;
  180. }
  181. }
  182.  
  183. public void attachClean(Person instance) {
  184. log.debug("attaching clean Person instance");
  185. try {
  186. getHibernateTemplate().lock(instance, LockMode.NONE);
  187. log.debug("attach successful");
  188. } catch (RuntimeException re) {
  189. log.error("attach failed", re);
  190. throw re;
  191. }
  192. }
  193.  
  194. public static PersonDAO getFromApplicationContext(ApplicationContext ctx) {
  195. return (PersonDAO) ctx.getBean("PersonDAO");
  196. }
  197. //输入Hql查询函数
  198. public List findByHql( String hql) {
  199. log.debug("finding Admin By Hql");
  200. try {
  201. String queryString = hql;
  202. return getHibernateTemplate().find(queryString);
  203. } catch (RuntimeException re) {
  204. log.error("find all failed", re);
  205. throw re;
  206. }
  207. }
  208. }

Service层:

  1. package com.hwadee.tradeUnion.service;
  2.  
  3. import java.util.List;
  4.  
  5. import javax.annotation.Resource;
  6.  
  7. import org.springframework.stereotype.Component;
  8.  
  9. import com.hwadee.tradeUnion.dao.PersonDAO;
  10.  
  11. import com.hwadee.tradeUnion.model.Person;
  12.  
  13. @Component
  14. public class PersonService {
  15.  
  16. private PersonDAO personDAO;
  17.  
  18. public PersonDAO getPersonDAO() {
  19. return personDAO;
  20. }
  21.  
  22. @Resource
  23. public void setPersonDAO(PersonDAO personDAO) {
  24. this.personDAO = personDAO;
  25. }
  26.  
  27. public void add(Person kxw) {
  28.  
  29. personDAO.save(kxw);
  30.  
  31. }
  32.  
  33. public void delete(Person kxw) {
  34.  
  35. personDAO.delete(kxw);
  36. }
  37.  
  38. public void deleteById(int id) {
  39.  
  40. personDAO.deleteById(id);
  41. }
  42.  
  43. public List<Person> list() {
  44.  
  45. return personDAO.findAll();
  46.  
  47. }
  48.  
  49. public Person loadById(int id) {
  50.  
  51. return personDAO.findById(id);
  52. }
  53.  
  54. public void update(Person kxw) {
  55.  
  56. personDAO.update(kxw);
  57.  
  58. }

Action层:

  1. package com.hwadee.tradeUnion.action;
  2.  
  3. import java.util.List;
  4.  
  5. import javax.annotation.Resource;
  6.  
  7. import org.springframework.stereotype.Component;
  8.  
  9. import com.hwadee.tradeUnion.model.Person;
  10. import com.hwadee.tradeUnion.service.PersonService;
  11. import com.opensymphony.xwork2.ActionSupport;
  12.  
  13. @Component("PersonAction")
  14. public class PersonAction extends ActionSupport {
  15.  
  16. /**
  17. *
  18. */
  19. private static final long serialVersionUID = 1L;
  20.  
  21. private List<Person> personList;
  22.  
  23. private PersonService personService;
  24. private Person person;
  25. private int id;
  26.  
  27. public PersonService getPersonService() {
  28. return personService;
  29. }
  30.  
  31. @Resource
  32. public void setPersonService(PersonService personService) {
  33. this.personService = personService;
  34. }
  35.  
  36. public String list() {
  37. personList = personService.list();
  38.  
  39. return SUCCESS;
  40. }
  41.  
  42. public String add() {
  43. personService.add(person);
  44.  
  45. return SUCCESS;
  46. }
  47. public String update() {
  48. personService.update(person);
  49. return SUCCESS;
  50. }
  51. public String delete() {
  52.  
  53. personService.deleteById(id);
  54. return SUCCESS;
  55. }
  56. public String addInput() {
  57.  
  58. return INPUT;
  59. }
  60. public String updateInput() {
  61. this.person = this.personService.loadById(id);
  62. return INPUT;
  63. }
  64.  
  65. public String load(){
  66.  
  67. this.person=this.personService.loadById(id);
  68.  
  69. return SUCCESS;
  70. }
  71.  
  72. public List<Person> getPersonList() {
  73. return personList;
  74. }
  75.  
  76. public void setPersonList(List<Person> personList) {
  77. this.personList = personList;
  78. }
  79.  
  80. public Person getPerson() {
  81. return person;
  82. }
  83.  
  84. public void setPerson(Person person) {
  85. this.person = person;
  86. }
  87.  
  88. public int getId() {
  89. return id;
  90. }
  91.  
  92. public void setId(int id) {
  93. this.id = id;
  94. }
  95.  
  96. }

applicationContext.xml文件:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xmlns:context="http://www.springframework.org/schema/context"
  5. xmlns:aop="http://www.springframework.org/schema/aop"
  6. xmlns:tx="http://www.springframework.org/schema/tx"
  7. xsi:schemaLocation="http://www.springframework.org/schema/beans
  8. http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
  9. http://www.springframework.org/schema/context
  10. http://www.springframework.org/schema/context/spring-context-3.2.xsd
  11. http://www.springframework.org/schema/aop
  12. http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
  13. http://www.springframework.org/schema/tx
  14. http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">
  15.  
  16. <context:annotation-config />
  17. <context:component-scan base-package="com.hwadee" />
  18. <!--
  19. <bean id="dataSource"
  20. class="org.apache.commons.dbcp.BasicDataSource"
  21. destroy-method="close">
  22.  
  23. <property name="driverClassName" value="com.mysql.jdbc.Driver" />
  24. <property name="url" value="jdbc:mysql://localhost:3306/spring" />
  25. <property name="username" value="root" />
  26. <property name="password" value="bjsxt" />
  27. </bean>
  28. -->
  29.  
  30. <bean
  31. class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  32. <property name="locations">
  33. <value>classpath:jdbc.properties</value>
  34. </property>
  35. </bean>
  36.  
  37. <bean id="dataSource" destroy-method="close"
  38. class="org.apache.commons.dbcp.BasicDataSource">
  39. <property name="driverClassName"
  40. value="${jdbc.driverClassName}" />
  41. <property name="url" value="${jdbc.url}" />
  42. <property name="username" value="${jdbc.username}" />
  43. <property name="password" value="${jdbc.password}" />
  44. </bean>
  45.  
  46. <bean id="sessionFactory"
  47. class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
  48. <property name="dataSource" ref="dataSource" />
  49. <!--
  50. <property name="annotatedClasses">
  51. <list>
  52. <value>com.bjsxt.model.User</value>
  53. <value>com.bjsxt.model.Log</value>
  54. </list>
  55. </property>
  56. -->
  57. <property name="packagesToScan">
  58. <list>
  59. <value>com.hwadee.tradeUnion.model</value>
  60.  
  61. </list>
  62. </property>
  63. <property name="hibernateProperties">
  64. <props>
  65. <prop key="hibernate.dialect">
  66. org.hibernate.dialect.MySQLDialect
  67. </prop>
  68. <prop key="hibernate.show_sql">true</prop>
  69. <prop key="hibernate.hbm2ddl.auto">update</prop>
  70. <prop key="hibernate.format_sql">true</prop>
  71. </props>
  72. </property>
  73. </bean>
  74.  
  75. <!-- <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
  76. <property name="sessionFactory" ref="sessionFactory"></property>
  77. </bean>-->
  78.  
  79. <bean id="txManager"
  80. class="org.springframework.orm.hibernate3.HibernateTransactionManager">
  81. <property name="sessionFactory" ref="sessionFactory" />
  82. </bean>
  83.  
  84. <aop:config>
  85. <aop:pointcut id="bussinessService"
  86. expression="execution(public * com.hwadee.tradeUnion.service.*.*(..))" />
  87. <aop:advisor pointcut-ref="bussinessService"
  88. advice-ref="txAdvice" />
  89. </aop:config>
  90.  
  91. <tx:advice id="txAdvice" transaction-manager="txManager">
  92. <tx:attributes>
  93. <!--<tx:method name="exists" read-only="true" /> -->
  94. <tx:method name="list" read-only="true" />
  95. <tx:method name="add*" propagation="REQUIRED"/>
  96. <tx:method name="loadById*" read-only="true"/>
  97. <tx:method name="delete*" propagation="REQUIRED"/>
  98. <tx:method name="deleteById*" propagation="REQUIRED"/>
  99. <tx:method name="update*" propagation="REQUIRED"/>
  100. </tx:attributes>
  101. </tx:advice>
  102.  
  103. </beans>

web.xml文件:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
  3.  
  4. <display-name>Struts Blank</display-name>
  5.  
  6. <welcome-file-list>
  7. <welcome-file>index.jsp</welcome-file>
  8. </welcome-file-list>
  9.  
  10. <!--如果不定义webAppRootKey参数,那么webAppRootKey就是缺省的"webapp.root"-->
  11.  
  12. <!-- <context-param>
  13.  
  14. <param-name>webAppRootKey</param-name>
  15.  
  16. <param-value>ssh.root</param-value>
  17.  
  18. </context-param>-->
  19.  
  20. <context-param>
  21.  
  22. <param-name>log4jConfigLocation</param-name>
  23.  
  24. <param-value>classpath:log4j.properties</param-value>
  25.  
  26. </context-param>
  27.  
  28. <context-param>
  29.  
  30. <param-name>log4jRefreshInterval</param-name>
  31.  
  32. <param-value>60000</param-value>
  33.  
  34. </context-param>
  35. <!--配置log4j -->
  36.  
  37. <listener>
  38.  
  39. <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
  40.  
  41. </listener>
  42.  
  43. <listener>
  44. <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  45. <!-- default: /WEB-INF/applicationContext.xml -->
  46. </listener>
  47.  
  48. <context-param>
  49. <param-name>contextConfigLocation</param-name>
  50. <!-- <param-value>/WEB-INF/applicationContext-*.xml,classpath*:applicationContext-*.xml</param-value> -->
  51. <param-value>classpath:applicationContext.xml</param-value>
  52. </context-param>
  53.  
  54. <filter>
  55. <filter-name>encodingFilter</filter-name>
  56. <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
  57. <init-param>
  58. <param-name>encoding</param-name>
  59. <param-value>GBK</param-value>
  60. </init-param>
  61. </filter>
  62.  
  63. <filter-mapping>
  64. <filter-name>encodingFilter</filter-name>
  65. <url-pattern>/*</url-pattern>
  66. </filter-mapping>
  67.  
  68. <filter>
  69. <filter-name>openSessionInView</filter-name>
  70. <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
  71. <init-param>
  72. <param-name>sessionFactoryBeanName</param-name>
  73. <param-value>sessionFactory</param-value>
  74. </init-param>
  75. </filter>
  76.  
  77. <filter-mapping>
  78. <filter-name>openSessionInView</filter-name>
  79. <url-pattern>/*</url-pattern>
  80. </filter-mapping>
  81.  
  82. <filter>
  83. <filter-name>struts2</filter-name>
  84. <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
  85. </filter>
  86.  
  87. <filter-mapping>
  88. <filter-name>struts2</filter-name>
  89. <url-pattern>/*</url-pattern>
  90. </filter-mapping>
  91.  
  92. </web-app>

jdbc.properties:

  1. jdbc.driverClassName=com.mysql.jdbc.Driver
  2. jdbc.url=jdbc:mysql://localhost:3300/TradeUnion
  3. jdbc.username=root
  4. jdbc.password=123456

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>
 
    <constant name="struts.devMode" value="true" />

<package name="default" namespace="/" extends="struts-default">

<action name="hello">
            <result>
                /hello.jsp
            </result>
        </action>
        
            <action name="*Login" class="{1}LoginAction">
          <result name="success">/{1}/{1}-Manage.jsp</result>
     <result name="fail">fail.jsp</result>
        </action>
           
        
 <action name="*-*-*" class="{2}Action" method="{3}">
          <result name="success">/{1}/{2}-{3}.jsp</result>
            <result name="input">/{1}/{2}-{3}.jsp</result>
          <result name="fail">/{1}/{2}-{3}-fail.jsp</result>
     
        </action>
        
    </package>
    
    <!-- Add packages here -->

</struts>

[置顶] struts2+hibernate+spring整合(annotation版)的更多相关文章

  1. Struts2+Hibernate+Spring 整合示例

    转自:https://blog.csdn.net/tkd03072010/article/details/7468769 Struts2+Hibernate+Spring 整合示例 Spring整合S ...

  2. Struts2+Hibernate+Spring 整合示例[转]

    原文 http://blog.csdn.net/tkd03072010/article/details/7468769 Spring整合Struts2.Hibernate原理概述: 从用户角度来看,用 ...

  3. Struts2 Spring Hibernate 框架整合 Annotation MavenProject

    项目结构目录 pom.xml       添加和管理jar包 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns ...

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

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

  5. Spring+Struts2+Hibernate的整合

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

  6. struts2+hibernate+spring简单整合且java.sql.SQLException: No suitable driver 问题解决

    最近上j2ee的课,老师要求整合struts2+hibernate+spring,我自己其实早早地有准备弄的,现在都第9个项目了,无奈自己的思路和头绪把自己带坑了,当然也是经验问题,其实只是用myec ...

  7. 工作笔记3.手把手教你搭建SSH(struts2+hibernate+spring)环境

    上文中我们介绍<工作笔记2.软件开发经常使用工具> 从今天開始本文将教大家怎样进行开发?本文以搭建SSH(struts2+hibernate+spring)框架为例,共分为3步: 1)3个 ...

  8. 二十六:Struts2 和 spring整合

    二十六:Struts2 和 spring整合 将项目名称为day29_02_struts2Spring下的scr目录下的Struts.xml文件拷贝到新项目的scr目录下 在新项目的WebRoot-- ...

  9. 第一次做的struts2与spring整合

    参考:http://www.cnblogs.com/S-E-P/archive/2012/01/18/2325253.html 这篇文章说的关键就是“除了导入Struts2和Spring的核心库之外, ...

随机推荐

  1. PHP读取文件夹的文件列表

    /** * getDir()取文件夹列表,getFile()取对应文件夹下面的文件列表,二者的区别在于判断有没有“.”后缀的文件,其他都一样 */ //获取文件目录列表,该方法返回数组 functio ...

  2. BZOJ 1901: Zju2112 Dynamic Rankings 区间k大 带修改 在线 线段树套平衡树

    之前写线段树套splay数组版..写了6.2k..然后弃疗了.现在发现还是很水的..嘎嘎.. zju过不了,超时. upd:才发现zju是多组数据..TLE一版才发现.然后改了,MLE...手写内存池 ...

  3. pc、移动端H5网站 QQ在线客服、群链接代码【我和qq客服的那些事儿】

    转载:http://blog.csdn.net/fungleo/article/details/51835368#comments 移动端H5 QQ在线客服链接代码 <a href=" ...

  4. 转:智能模糊测试工具 Winafl 的使用与分析

    本文为 椒图科技 授权嘶吼发布,如若转载,请注明来源于嘶吼: http://www.4hou.com/technology/2800.html 注意: 函数的偏移地址计算方式是以IDA中出现的Imag ...

  5. 234. Palindrome Linked List【Easy】【判断链表是否回文】

    Given a singly linked list, determine if it is a palindrome. Example 1: Input: 1->2 Output: false ...

  6. [BZOJ5248][九省联考2018]一双木棋(连通性DP,对抗搜索)

    5248: [2018多省省队联测]一双木棋 Time Limit: 20 Sec  Memory Limit: 512 MBSubmit: 43  Solved: 34[Submit][Status ...

  7. [Codeforces-div.1 167B] Wizards and Huge Prize

    [Codeforces-div.1 167B] Wizards and Huge Prize 试题分析 注意到每个物品互相独立,互不干扰之后就非常好做了. 算出一个物品最后的价值期望,然后乘以K即可. ...

  8. 【POJ】1089Intervals

    Intervals Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 8276   Accepted: 3270 Descrip ...

  9. BZOJ 3790 神奇项链(manacher+DP+树状数组)

    [题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=3790 [题目大意] 问最少用几个回文串可以构成给出串,重叠部分可以合并 [题解] 我们 ...

  10. 【动态规划+高精度】mr360-定长不下降子序列

    [题目大意] 韵哲君发现自己的面前有一行数字,当她正在琢磨应该干什么的时候,这时候,陈凡老师从天而降,走到了韵哲君的身边,低下头,对她耳语了几句,然后飘然而去. 陈凡老师说了什么呢,陈凡老师对韵哲君说 ...