`
chenying998179
  • 浏览: 25682 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Spring MVC3 Hibernate CRUD Sample Application

    博客分类:
  • java
 
阅读更多

To learn any web framework starting with a HelloWorld application is a good idea. Once we get familiarity with the framework configuration it would be better to do a CRUD (Create,Read,Update,Delete) application which covers various aspects of a web framework like Validations, Request URL Mappings, Request Parameter Binding, Pre-populating forms etc.

Now I am going to explain how to write a Simple CRUD application using Spring MVC3, Hibernate and MySQL. Our Application is ContactsManagements where you can view or search contacts, create new contacts, edit or delete existing contacts.

Step#1: Create the CONTACTS Table

CREATE TABLE  CONTACTS
(
  id int(10) unsigned NOT NULL AUTO_INCREMENT,
  name varchar(45) NOT NULL,
  address varchar(45) DEFAULT NULL,
  gender char(1) DEFAULT 'M',
  dob datetime DEFAULT NULL,
  email varchar(45) DEFAULT NULL,
  mobile varchar(15) DEFAULT NULL,
  phone varchar(15) DEFAULT NULL,
  PRIMARY KEY (id)
);

Step#2: Copy the SpringMVC, Hibernate and their dependent jars into WEB-INF/lib folder. If you are using Maven you can mention the following dependencies.

<dependencies>
  <dependency>
    <groupid>junit</groupid>
    <artifactid>junit</artifactid>
    <version>4.8.1</version>
    <type>jar</type>
    <scope>compile</scope>
   </dependency>
   <dependency>
     <groupid>org.springframework</groupid>
     <artifactid>spring-web</artifactid>
     <version>3.0.5.RELEASE</version>
     <type>jar</type>
     <scope>compile</scope>
    </dependency>
    <dependency>
     <groupid>org.springframework</groupid>
     <artifactid>spring-core</artifactid>
     <version>3.0.5.RELEASE</version>
     <type>jar</type>
     <scope>compile</scope>
     <exclusions>
      <exclusion>
       <artifactid>commons-logging</artifactid>
       <groupid>commons-logging</groupid>
      </exclusion>
     </exclusions>
    </dependency>
    <dependency>
     <groupid>log4j</groupid>
     <artifactid>log4j</artifactid>
     <version>1.2.14</version>
     <type>jar</type>
     <scope>compile</scope>
    </dependency>
    <dependency>
     <groupid>org.springframework</groupid>
     <artifactid>spring-tx</artifactid>
     <version>3.0.5.RELEASE</version>
     <type>jar</type>
     <scope>compile</scope>
    </dependency>
    <dependency>
     <groupid>jstl</groupid>
     <artifactid>jstl</artifactid>
     <version>1.1.2</version>
     <type>jar</type>
     <scope>compile</scope>
    </dependency>
    <dependency>
     <groupid>taglibs</groupid>
     <artifactid>standard</artifactid>
     <version>1.1.2</version>
     <type>jar</type>
     <scope>compile</scope>
    </dependency>
    <dependency>
     <groupid>org.springframework</groupid>
     <artifactid>spring-webmvc</artifactid>
     <version>3.0.5.RELEASE</version>
     <type>jar</type>
     <scope>compile</scope>
    </dependency>
    <dependency>
     <groupid>org.springframework</groupid>
     <artifactid>spring-aop</artifactid>
     <version>3.0.5.RELEASE</version>
     <type>jar</type>
     <scope>compile</scope>
    </dependency>
    <dependency>
     <groupid>commons-digester</groupid>
     <artifactid>commons-digester</artifactid>
     <version>2.1</version>
     <type>jar</type>
     <scope>compile</scope>
    </dependency>
    <dependency>
     <groupid>commons-collections</groupid>
     <artifactid>commons-collections</artifactid>
     <version>3.2.1</version>
     <type>jar</type>
     <scope>compile</scope>
    </dependency>
    <dependency>
     <groupid>org.hibernate</groupid>
     <artifactid>hibernate-core</artifactid>
     <version>3.3.2.GA</version>
     <type>jar</type>
     <scope>compile</scope>
    </dependency>
    <dependency>
     <groupid>javax.persistence</groupid>
     <artifactid>persistence-api</artifactid>
     <version>1.0</version>
     <type>jar</type>
     <scope>compile</scope>
    </dependency>
    <dependency>
     <groupid>c3p0</groupid>
     <artifactid>c3p0</artifactid>
     <version>0.9.1.2</version>
     <type>jar</type>
     <scope>compile</scope>
    </dependency>
    <dependency>
     <groupid>org.springframework</groupid>
     <artifactid>spring-orm</artifactid>
     <version>3.0.5.RELEASE</version>
     <type>jar</type>
     <scope>compile</scope>
    </dependency>
    <dependency>
     <groupid>org.slf4j</groupid>
     <artifactid>slf4j-api</artifactid>
     <version>1.6.1</version>
     <type>jar</type>
     <scope>compile</scope>
    </dependency>
    <dependency>
     <groupid>org.slf4j</groupid>
     <artifactid>slf4j-log4j12</artifactid>
     <version>1.6.1</version>
     <type>jar</type>
     <scope>compile</scope>
    </dependency>
    <dependency>
     <groupid>cglib</groupid>
     <artifactid>cglib-nodep</artifactid>
     <version>2.2</version>
     <type>jar</type>
     <scope>compile</scope>
    </dependency>
    <dependency>
     <groupid>org.hibernate</groupid>
     <artifactid>hibernate-annotations</artifactid>
     <version>3.4.0.GA</version>
     <type>jar</type>
     <scope>compile</scope>
    </dependency>
    <dependency>
     <groupid>jboss</groupid>
     <artifactid>javassist</artifactid>
     <version>3.7.ga</version>
     <type>jar</type>
     <scope>compile</scope>
    </dependency>
    <dependency>
     <groupid>mysql</groupid>
     <artifactid>mysql-connector-java</artifactid>
     <version>5.1.14</version>
     <type>jar</type>
     <scope>compile</scope>
    </dependency>
  </dependencies>

Step#3: Configure SpringMVC

a) Configure DispatcherServlet in web.xml

<servlet>
  <servlet-name>dispatcher</servlet-name>
  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  <load-on-startup>1</load-on-startup>
 </servlet>
  
 <servlet-mapping>
  <servlet-name>dispatcher</servlet-name>
  <url-pattern>*.do</url-pattern>
 </servlet-mapping>
 
 <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>

b) Configure View Resolver in WEB-INF/dispatcher-servlet.xml

<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" 
 p:prefix="/jsp/" p:suffix=".jsp">
</bean>

c) Configure Annotation support, PropertyPlaceHolderConfigurer, ResourceBundleMessageSource in WEB-INF/classes/applicationContext.xml

<context:annotation-config></context:annotation-config>

<context:component-scan base-package="com.sivalabs"></context:component-scan>

<mvc:annotation-driven> </mvc:annotation-driven>

<context:property-placeholder location="classpath:config.properties"></context:property-placeholder>

<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource" 
 p:basename="Messages"></bean>

Step#4: Configure JDBC connection parameters and Hibernate properties in config.properties

################### JDBC Configuration ##########################
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/sivalabs
jdbc.username=root
jdbc.password=admin
 
################### Hibernate Configuration ##########################
hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.show_sql=true
#hibernate.hbm2ddl.auto=update
hibernate.generate_statistics=true

Step#5: Configure DataSource, SessionFactory, TransactionManagement support in WEB-INF/classes/applicationContext.xml

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" 
 p:driverclassname="${jdbc.driverClassName}" p:url="${jdbc.url}" p:username="${jdbc.username}" p:password="${jdbc.password}">
</bean> 

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
 <property name="dataSource" ref="dataSource"></property>
 <property name="hibernateProperties">
  <props>       
  <prop key="hibernate.dialect">${hibernate.dialect}</prop>         
  <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
  </props>
 </property>
 <property name="packagesToScan" value="com.sivalabs"></property>
</bean>


<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager" 
  p:sessionfactory-ref="sessionFactory">
</bean>

<tx:annotation-driven transaction-manager="transactionManager"></tx:annotation-driven>

Step#6: Configure the Labels, error messages in WEB-INF/classes/Messages.properties

App.Title=SivaLabs
typeMismatch.java.util.Date={0} is Invalid Date.
dob=DOB

Step#7: Create the Entity class Contact.java

package com.sivalabs.contacts;
 
import java.util.Date;
 
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
 
import org.apache.commons.lang.builder.ToStringBuilder;
 
@Entity
@Table(name="CONTACTS")
public class Contact
{
 @Id
 @GeneratedValue(strategy = GenerationType.AUTO)
 private int id;
 @Column private String name;
 @Column private String address;
 @Column private String gender;
 @Column private Date dob;
 @Column private String email;
 @Column private String mobile;
 @Column private String phone;
  
 @Override
 public String toString()
 {
  return ToStringBuilder.reflectionToString(this);
 }
 //setters & getters
}

Step#8: Create the ContactsDAO.java which performs CRUD operations on CONTACTS table.

package com.sivalabs.contacts;
 
import java.util.List;
 
import org.hibernate.Criteria;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
 
@Repository
@Transactional
public class ContactsDAO
{
 @Autowired
 private SessionFactory sessionFactory;
  
 public Contact getById(int id)
 {
  return (Contact) sessionFactory.getCurrentSession().get(Contact.class, id);
 }
  
 @SuppressWarnings("unchecked")
 public List searchContacts(String name)
 {
  Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Contact.class);
  criteria.add(Restrictions.ilike("name", name+"%"));
  return criteria.list();
 }
  
 @SuppressWarnings("unchecked")
 public List getAllContacts()
 {
  Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Contact.class);
  return criteria.list();
 }
  
 public int save(Contact contact)
 {
  return (Integer) sessionFactory.getCurrentSession().save(contact);
 }
  
 public void update(Contact contact)
 {
  sessionFactory.getCurrentSession().merge(contact);
 }
  
 public void delete(int id)
 {
  Contact c = getById(id);
  sessionFactory.getCurrentSession().delete(c);
 }
}

Step#9: Create ContactFormValidator.java which performs the validations on saving/updating a contact.

package com.sivalabs.contacts;
 
import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;
 
@Component("contactFormValidator")
public class ContactFormValidator implements Validator
{
 @SuppressWarnings("unchecked")
 @Override
 public boolean supports(Class clazz)
 {
  return Contact.class.isAssignableFrom(clazz);
 }
 
 @Override
 public void validate(Object model, Errors errors)
 {
  ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name","required.name", "Name is required.");
 }
}

Step#10: Create ContactsControllers.java which processes all the CRUD requests.

package com.sivalabs.contacts;
 
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.support.SessionStatus;
import org.springframework.web.servlet.ModelAndView;
 
@Controller
public class ContactsControllers
{
 @Autowired
 private ContactsDAO contactsDAO;
  
 @Autowired
 private ContactFormValidator validator;
   
 @InitBinder
 public void initBinder(WebDataBinder binder)
 {
  SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
  dateFormat.setLenient(false);
  binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
 }
   
 @RequestMapping("/searchContacts")
 public ModelAndView searchContacts(@RequestParam(required= false, defaultValue="") String name)
 {
  ModelAndView mav = new ModelAndView("showContacts");
  List contacts = contactsDAO.searchContacts(name.trim());
  mav.addObject("SEARCH_CONTACTS_RESULTS_KEY", contacts);
  return mav;
 }
  
 @RequestMapping("/viewAllContacts")
 public ModelAndView getAllContacts()
 {
  ModelAndView mav = new ModelAndView("showContacts");
  List contacts = contactsDAO.getAllContacts();
  mav.addObject("SEARCH_CONTACTS_RESULTS_KEY", contacts);
  return mav;
 }
  
 @RequestMapping(value="/saveContact", method=RequestMethod.GET)
 public ModelAndView newuserForm()
 {
  ModelAndView mav = new ModelAndView("newContact");
  Contact contact = new Contact();
  mav.getModelMap().put("newContact", contact);
  return mav;
 }
  
 @RequestMapping(value="/saveContact", method=RequestMethod.POST)
 public String create(@ModelAttribute("newContact")Contact contact, BindingResult result, SessionStatus status)
 {
  validator.validate(contact, result);
  if (result.hasErrors())
  {   
   return "newContact";
  }
  contactsDAO.save(contact);
  status.setComplete();
  return "redirect:viewAllContacts.do";
 }
  
 @RequestMapping(value="/updateContact", method=RequestMethod.GET)
 public ModelAndView edit(@RequestParam("id")Integer id)
 {
  ModelAndView mav = new ModelAndView("editContact");
  Contact contact = contactsDAO.getById(id);
  mav.addObject("editContact", contact);
  return mav;
 }
  
 @RequestMapping(value="/updateContact", method=RequestMethod.POST)
 public String update(@ModelAttribute("editContact") Contact contact, BindingResult result, SessionStatus status)
 {
  validator.validate(contact, result);
  if (result.hasErrors()) {
   return "editContact";
  }
  contactsDAO.update(contact);
  status.setComplete();
  return "redirect:viewAllContacts.do";
 }
   
 @RequestMapping("deleteContact")
 public ModelAndView delete(@RequestParam("id")Integer id)
 {
  ModelAndView mav = new ModelAndView("redirect:viewAllContacts.do");
  contactsDAO.delete(id);
  return mav;
 }
}

Step#11: Instead of writing the JSTL tag library declerations in all the JSPs, declare them in one JSP and include that JSP in other JSPs.

taglib_includes.jsp

<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
 
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>

Step#12: Create the JSPs.

a)showContacts.jsp

<%@include file="taglib_includes.jsp" %>
 
<html>
<head>
 
<title><spring:message code="App.Title"></spring:message> </title>
<script type="text/javascript" src="js/contacts.js"></script>
</head>
<body style="font-family: Arial; font-size:smaller;">
 <center>
 <form action="searchContacts.do" method="post"><table style="border-collapse: collapse;" width="500" border="0" bordercolor="#006699"><tbody><tr>     <td>Enter Contact Name</td>      <td><input name="name" type="text">
 
  <input value="Search" type="submit">
 
  <input value="New Contact" onclick="javascript:go('saveContact.do');" type="button">
 
</td></tr>
</tbody></table></form><c:if test="${empty SEARCH_CONTACTS_RESULTS_KEY}">
</c:if><c:if test="${! empty SEARCH_CONTACTS_RESULTS_KEY}">    <c:foreach var="contact" items="${SEARCH_CONTACTS_RESULTS_KEY}">
</c:foreach></c:if><table style="border-collapse: collapse;" width="500" border="1" bordercolor="#006699"><tbody><tr bgcolor="lightblue">    <th>Id</th>    <th>Name</th>       <th>Address</th>     <th>Mobile</th>    <th></th>   </tr>
<tr>    <td colspan="4">No Results found</td>   </tr>
   <tr>     <td><c:out value="${contact.id}"></c:out></td>     <td><c:out value="${contact.name}"></c:out></td>     <td><c:out value="${contact.address}"></c:out> </td>     <td><c:out value="${contact.mobile}"></c:out></td>     <td>
 
 <a href="updateContact.do?id=$%7Bcontact.id%7D">Edit</a>
 
  <a href="javascript:deleteContact('deleteContact.do?id=${contact.id}');">Delete</a>
 
</td>    </tr>
         </tbody></table></center>
   
</body>
</html>

b)newContact.jsp

<%@include file="taglib_includes.jsp" %>
 
<html>
<head>
 <script type="text/javascript" src="js/contacts.js"></script>
 <title><spring:message code="App.Title"></spring:message> </title>
</head>
<body style="font-family: Arial; font-size:smaller;">
 
<table style="border-collapse: collapse;" width="750" align="center" bgcolor="lightblue" border="1" bordercolor="#006699" height="500"><tbody><tr>   <td align="center"><h3>Edit Contact Form</h3></td>  </tr>
<tr valign="top" align="center">     <td align="center">
 
<form:form action="saveContact.do" method="post" commandname="newContact"><table style="border-collapse: collapse;" width="500" border="0" bordercolor="#006699" cellpadding="2" cellspacing="2"><tbody><tr>       <td width="100" align="right">Name</td>       <td width="150">
 
<form:input path="name"></form:input></td>       <td align="left">
 
<form:errors path="name" cssstyle="color:red"></form:errors></td>      </tr>
<tr>       <td width="100" align="right">DOB</td>       <td><form:input path="dob"></form:input></td>       <td align="left"><form:errors path="dob" cssstyle="color:red"></form:errors></td>      </tr>
<tr>       <td width="100" align="right">Gender</td>       <td>     
 
<form:select path="gender"><form:option value="M" label="Male"><form:option value="F" label="Female"></form:option></form:option></form:select></td>       <td>
 
</td>            </tr>
<tr>       <td width="100" align="right">Address</td>       <td><form:input path="address"></form:input></td>       <td align="left">
 
<form:errors path="address" cssstyle="color:red"></form:errors></td>      </tr>
<tr>       <td width="100" align="right">Email</td>       <td><form:input path="email"></form:input></td>       <td align="left"><form:errors path="email" cssstyle="color:red"></form:errors></td>      </tr>
<tr>       <td width="100" align="right">Mobile</td>       <td><form:input path="mobile"></form:input></td>       <td align="left">
 
<form:errors path="mobile" cssstyle="color:red"></form:errors></td>      </tr>
<tr>       <td colspan="3" align="center">
 
<input name="" value="Save" type="submit">
 
   
 
<input name="" value="Reset" type="reset">
 
   
 
<input value="Back" onclick="javascript:go('viewAllContacts.do');" type="button">
 
</td>      </tr>
</tbody></table></form:form></td>       </tr>
</tbody></table></body>
</html>

a)editContact.jsp

<%@include file="taglib_includes.jsp" %>
 
<html>
<head>
 <script type="text/javascript" src="js/contacts.js"></script>
 <title><spring:message code="App.Title"></spring:message> </title>
</head>
<body style="font-family: Arial; font-size:smaller;">
 
<table style="border-collapse: collapse;" width="750" align="center" bgcolor="lightblue" border="1" bordercolor="#006699" height="500"><tbody><tr>   <td align="center"><h3>Edit Contact Form</h3></td>  </tr>
<tr valign="top" align="center">     <td align="center">
 
<form:form action="updateContact.do" method="post" commandname="editContact"><table style="border-collapse: collapse;" width="500" border="0" bordercolor="#006699" cellpadding="2" cellspacing="2"><tbody><tr>       <td width="100" align="right">Id</td>       <td width="150">
 
<form:input path="id" readonly="true"></form:input></td>       <td align="left">
 
<form:errors path="id" cssstyle="color:red"></form:errors></td>      </tr>
<tr>       <td width="100" align="right">Name</td>       <td>
 
<form:input path="name"></form:input></td>       <td align="left">
 
<form:errors path="name" cssstyle="color:red"></form:errors></td>      </tr>
<tr>       <td width="100" align="right">DOB</td>       <td><form:input path="dob"></form:input></td>       <td align="left"><form:errors path="dob" cssstyle="color:red"></form:errors></td>      </tr>
<tr>       <td width="100" align="right">Gender</td>       <td>     
 
<form:select path="gender"><form:option value="M" label="Male"><form:option value="F" label="Female"></form:option></form:option></form:select></td>       <td>
 
</td>            </tr>
<tr>       <td width="100" align="right">Address</td>       <td><form:input path="address"></form:input></td>       <td align="left">
 
<form:errors path="address" cssstyle="color:red"></form:errors></td>      </tr>
<tr>       <td width="100" align="right">Email</td>       <td><form:input path="email"></form:input></td>       <td align="left"><form:errors path="email" cssstyle="color:red"></form:errors></td>      </tr>
<tr>       <td width="100" align="right">Mobile</td>       <td><form:input path="mobile"></form:input></td>       <td align="left">
 
<form:errors path="mobile" cssstyle="color:red"></form:errors></td>      </tr>
<tr valign="bottom">       <td colspan="3" align="center">
 
<input value="Delete" onclick="javascript:deleteContact('deleteContact.do?id=${editContact.id}');" type="button">
 
   
 
<input name="" value="Save" type="submit">     
 
   
 
<input value="Back" onclick="javascript:go('viewAllContacts.do');" type="button">
 
</td>      </tr>
</tbody></table></form:form></td>       </tr>
</tbody></table></body>
</html>

Step#13: Write the javascript file js/contacts.js containing the utility methods

function go(url)
{
 window.location = url;
}
 
function deleteContact(url)
{
 var isOK = confirm("Are you sure to delete?");
 if(isOK)
 {
  go(url);
 }
}

Step#14: The welcome file index.jsp

<%
response.sendRedirect("viewAllContacts.do");
%>

Step#15: Start the server and point your browser URL to http://localhost:8080/SpringMVCHibernate

Reference : Spring MVC3 Hibernate CRUD Sample Application from our JCG partner Siva from SivaLabs.
Related Articles:


Read more: http://www.javacodegeeks.com/2011/04/spring-mvc3-hibernate-crud-sample.html#ixzz1stdYTNhn
分享到:
评论

相关推荐

    Spring mvc+hibernate+mysql Demo

    【Spring MVC + Hibernate + MySQL 整合详解】 在IT领域,Spring MVC、Hibernate和MySQL是构建Web应用程序的常用技术栈。Spring MVC作为Spring框架的一部分,提供了强大的MVC(Model-View-Controller)架构,用于...

    spring mvc + spring + hibernate 全注解整合开发视频教程 11

    在这个视频教程中,你可能将学习到如何配置Spring的XML上下文文件以启用注解驱动的配置,如何在Spring MVC中创建注解式的控制器并处理HTTP请求,以及如何通过Hibernate的注解来设计数据模型并执行CRUD操作。...

    spring4MVC+Hibernate4实例(增删改查)

    在本实例中,"spring4MVC+Hibernate4实例(增删改查)"是一个基于Maven构建的Java Web项目,旨在演示如何整合Spring MVC和Hibernate框架来实现数据的CRUD(创建、读取、更新和删除)操作。Spring MVC是Spring框架的...

    spring mvc mysql hibernate

    标题中的“Spring MVC”,“Hibernate”和“MySQL”都是Java Web开发中不可或缺的重要技术组件,它们共同构建了一个高效、灵活的后端应用架构。 Spring MVC是Spring框架的一部分,专门用于构建Web应用程序。它是一...

    基于 Java ssh整合 开源博客系统 spring mvc,hibernate,spring,maven 整合开发

    例如,Spring MVC与Hibernate的结合,可以在Spring的管理下自动进行数据的CRUD操作,降低了数据库层的开发难度。同时,Spring的AOP特性可以实现全局事务管理,保证数据的一致性。Maven则简化了构建过程,使得团队...

    spring mvc + spring + hibernate 全注解整合开发视频教程 12

    在本教程中,我们将深入探讨如何使用Spring MVC、Spring和Hibernate三大框架进行全注解的整合开发。这个视频教程系列的第12部分,将帮助开发者掌握如何在Java Web项目中高效地集成这三个核心框架,实现松耦合、可...

    Spring MVC+hibernate helloworld

    Spring MVC和Hibernate是Java开发中常用的两个开源框架,它们分别负责Web层和持久化层的管理。本实例是一个基础的“Hello, World!”程序,旨在帮助初学者理解这两个框架的集成与基本用法,并引入了简单的验证功能。...

    Spring MVC+Hibernate&Ibatis学习 例子 教程

    Spring MVC、Hibernate和iBatis是Java开发中常用的三大框架,它们在Web应用程序开发中各自承担着不同的职责。本教程将深入探讨这三个框架的核心概念、使用方法以及它们之间的协同工作。 **Spring MVC** 是Spring...

    Spring-MVC-Hibernate-CRUD-源码.rar

    这是一个关于使用Spring MVC和Hibernate框架实现CRUD操作的源代码示例。CRUD代表创建(Create)、读取(Retrieve)、更新(Update)和删除(Delete),是数据库操作的基本功能。Spring MVC作为Spring框架的一部分,是用于...

    bbs.zip_Spring mvc bbs_hibernate bbs_spring mvc_spring mvc hiber

    本项目"Spring MVC bbs"结合了Spring3和Hibernate,构建了一个功能完备的BBS论坛系统,适合进行二次开发。下面我们将深入探讨这两个框架以及它们如何协同工作,实现高效的数据处理和用户交互。 Spring MVC是Spring...

    spring mvc+hibernate完整jar包

    Spring MVC 和 Hibernate 是两个在Java Web开发中广泛使用的框架,它们分别是用于构建MVC(Model-View-Controller)架构的Web应用和管理数据库操作的对象关系映射(ORM)工具。这个压缩包“spring_mvc_hibernate”很...

    Spring MVC + hibernate 集合

    【Spring MVC + Hibernate 整合详解】 Spring MVC 和 Hibernate 是两个在 Java Web 开发中广泛使用的框架。Spring MVC 是 Spring 框架的一部分,主要用于构建前端控制器,处理 HTTP 请求并分发到相应的业务逻辑。而...

    spring、spring mvc、hibernate 之零配置之路源代码

    在IT领域,Spring、Spring MVC和Hibernate是三个非常重要的开源框架,它们构成了Java Web开发的基础。这个"spring、spring mvc、hibernate 之零配置之路源代码"压缩包很可能是为了帮助开发者理解这三个框架如何协同...

    spring mvc+hibernate实现的用户管理系统

    在探讨Spring MVC和Hibernate框架整合实现的用户管理系统时,我们首先需要了解这个系统能够做什么以及它是如何构建的。Spring MVC和Hibernate是JavaEE开发中非常流行的框架,分别用于实现MVC设计模式和提供ORM(对象...

    spring mvc+hibernate 简单 实例 代码,新手入门

    3. **整合 Spring MVC 和 Hibernate:** - 通过 Spring 的声明式事务管理,可以在配置文件中定义事务边界,简化事务处理。 - 使用 Spring 的 DataSource 和 SessionFactory 配置,以便在 Spring 环境下管理 ...

    一个Spring MVC和Hibernate一起使用的个人暂存

    Spring MVC和Hibernate是Java开发中两个非常重要的框架,它们分别用于构建Web应用程序的MVC(Model-View-Controller)架构和持久层数据管理。在这个个人暂存中,开发者集成了这两个框架,创建了一个可能用于学习或...

    spring mvc,spring,hibernate框架开发

    Spring MVC、Spring 和 Hibernate 是 Java 开发中三个非常重要的框架,它们共同构成了企业级应用的基石,尤其是在构建大型、复杂的Web应用程序时。Spring MVC 作为Spring框架的一部分,负责处理HTTP请求,提供MVC...

    用IDEA开发的spring mvc+hibernate 例子

    在本文中,我们将深入探讨如何使用IntelliJ IDEA(IDEA)开发一个基于Spring MVC和Hibernate的Web应用程序。Spring MVC是Spring框架的一部分,用于构建强大的、模块化的Web应用,而Hibernate是一个流行的Java ORM...

    spring mvc+hibernate+extjs代码示例

    在Spring MVC中,Hibernate可以通过Spring的数据访问/集成(Data Access/Integration)支持进行配置,例如使用`SessionFactory`和`Session`对象进行CRUD操作。此外,还可以利用Hibernate的`@Entity`注解来标记实体类...

    spring boot jsp mvc jpa hibernate mysql 示例 sample

    这个示例项目可能包含了一个简单的 CRUD 应用,展示了如何通过 Spring Boot 结合 JSP、MVC、JPA 和 Hibernate 实现与 MySQL 数据库的交互。开发者可以通过学习这个样本,了解这些技术在实际项目中的整合和使用方式,...

Global site tag (gtag.js) - Google Analytics