Home » Java » Enterprise Java » Spring MVC3 Hibernate CRUD Sample Application

About Siva Reddy

Siva Reddy
Katamreddy Siva Prasad is a Senior Software Engineer working in E-Commerce domain. His areas of interest include Object Oriented Design, SOLID Design principles, RESTful WebServices and OpenSource softwares including Spring, MyBatis and Jenkins.

Spring MVC3 Hibernate CRUD Sample Application

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:

    Do you want to know how to develop your skillset to become a Java Rockstar?
    Subscribe to our newsletter to start Rocking right now!
    To get you started we give you our best selling eBooks for FREE!
    1. JPA Mini Book
    2. JVM Troubleshooting Guide
    3. JUnit Tutorial for Unit Testing
    4. Java Annotations Tutorial
    5. Java Interview Questions
    6. Spring Interview Questions
    7. Android UI Design
    and many more ....
    Email address:

    Leave a Reply

    3 Comments on "Spring MVC3 Hibernate CRUD Sample Application"

    avatar
      Subscribe  
    newest oldest most voted
    Notify of
    Michael Pitsounis
    Guest

    http://www.jprovocateur.org for spring, hibernate with generic dao  and extjs in 5 minutes , just define the mapping of the hibernate object, services and frontend are created on the fly 

    RaTm
    Guest

    Hello, Thanks for this sample.
    I agree with zonesny.. It would be much practical if you’ve posted zip containing the project and some screen shot showing the result after deploying the project on a web server.

    I finished the project, and deployed it on my web server, but when I point my browser on http://localhost:8080/SpringHibernateCRUD/viewAllContacts.do ,
    I get http-404.
    No error in the log files.
    I am using a hsqldb instead of mysql.

    Can you give me a tip?

    Thanks

    Erik
    Guest

    His source code was linked in the referenced article.

    http://www.sivalabs.in/2011/04/springmvc3-hibernate-crud-sample.html

    Want to take your Java skills to the next level?
    Grab our programming books for FREE!
    Here are some of the eBooks you will get:
    • Spring Interview QnA
    • Multithreading & Concurrency QnA
    • JPA Minibook
    • JVM Troubleshooting Guide
    • Advanced Java
    • Java Interview QnA
    • Java Design Patterns
    The Spring Framework Cookbook
    • Learn the best practices of the Spring Framework
    • Build simple, portable, fast and flexible JVM-based systems and applications
    • Explore specific projects like Boot and Batch
    The Spring Data Programming Cookbook
    • Learn how to use data access technologies and cloud-based data services
    • Set up the environment and create a basic project
    • Learn how to handle the various modules (e.g. JPA, MongoDB, Redis etc.)
    The Selenium Programming Cookbook
    • Kick-start your own projects using this testing framework for web applications
    • Learn JUnit integration and Standalone Server functionality
    • Find out the most popular Interview Questions about the Selenium Framework
    The Mockito Programming Cookbook
    • Kick-start your own web projects using this open source testing framework
    • Write simple test cases using the Mockito Framework
    • Learn how to integrate with JUnit, Maven and other frameworks
    The JUnit Programming Cookbook
    • Learn basic usage and configuration of JUnit
    • Create multithreaded tests
    • Learn how to integrate with other testing frameworks
    The JSF 2.0 Programming Cookbook
    • Build component-based user interfaces for web applications
    • Set up the environment and create a basic project
    • Learn Internationalization and Facelets Templates
    The Amazon S3 Tutorial
    • Develop your own Amazon S3 based applications
    • Learn API usage and pricing
    • Get your own projects up and running in minimum time
    Java Design Patterns
    • Learn how Design Patterns are implemented and utilized in Java
    • Understand the reasons why patterns are so important
    • Learn when and how to apply each one of them
    Java Concurrency Essentials
    • Dive into the magic of concurrency
    • Learn about concepts like atomicity, synchronization and thread safety
    • Learn about testing concurrent applications
    The IntelliJ IDEA Handbook
    • Kick-start your own programming projects using IntelliJ IDEA
    • Learn how to setup and install plugins
    • Create UIs with this Java integrated development environment
    The Git Tutorial
    • Learn why Git differs from other version control systems
    • Explore Git's usage and best practises
    • Learn branching strategies
    The Eclipse IDE Handbook
    • Explore the most widely used Java IDE
    • Learn how to setup and install plugins
    • Built your own projects up and running in minimum time
    The Docker Containerization Cookbook
    • Explore the world’s leading software containerization platform
    • Learn how to wrap a piece of software in a complete filesystem
    • Learn how to use DNS and various commands
    Developing Modern Applications With Scala
    • Develop modern Scala applications
    • Build SBT and reactive applications
    • Learn about testing and database access
    The Apache Tomcat Cookbook
    • Explore Apache Tomcat open-source web server
    • Learn about installation, configuration, logging and clustering
    • Kick-start your own web projects using Apache Tomcat
    The Apache Maven Cookbook
    • Explore the Apache Maven build automation tool
    • Learn about Maven's project structure and configuration
    • Learn about Maven's dependency management and plug-ins
    The Apache Hadoop Cookbook
    • Explore the Apache Hadoop open-source software framework
    • Learn distributed caching and streaming
    • Kick-start your own web projects using Apache Hadoop
    The Android Programming Cookbook
    • Explore the Android mobile operating system
    • Learn about services and page views
    • Learn about Google Maps and Bluetooth functionality
    The Elasticsearch Tutorial
    • Explore the Elasticsearch search engine
    • Develop your own Elasticsearch based applications
    • Learn operations, Java API Integration and reporting
    Amazon DynamoDB Tutorial
    • Develop your own Amazon DynamoDB based applications
    • Learn DynamoDB Concepts and Best Practices
    • Get your own projects up and running in minimum time
    Java NIO Programming Cookbook
    • Learn features for intensive I/O operations
    • Follow a series of tutorials on Java NIO examples
    • Get knowledge on Java Nio Socket and Asynchronous Channels
    JBoss Drools Cookbook
    • Explore Drools business rule management system
    • Follow a series of tutorials on Drools examples
    • Get knowledge on business rules for a shopping domain model
    Vaadin Programming Cookbook
    • Explore Vaadin web framework for rich Internet applications
    • Learn the Architecture and Best Practices
    • Get knowledge on Data Binding and Custom Components
    Groovy Programming Cookbook
    • Explore Apache Groovy object-oriented programming language
    • Create sample applications and explore interview questions
    • Get knowledge on Callback functionality and various widgets
    GWT Programming Cookbook
    • Explore the open source Google Web Toolkit
    • Create sample applications and explore interview questions
    • Create and maintain complex JavaScript front-end applications in Java
    Do you want to know how to develop your skillset to become a Java Rockstar?
    Subscribe to our newsletter to start Rocking right now!
    To get you started we give you our best selling eBooks for FREE!
    1. JPA Mini Book
    2. JVM Troubleshooting Guide
    3. JUnit Tutorial for Unit Testing
    4. Java Annotations Tutorial
    5. Java Interview Questions
    and many more ....
    Email address:
    Do you want to know how to develop your skillset to become a Java Rockstar?
    Subscribe to our newsletter to start Rocking right now!
    To get you started we give you our best selling eBooks for FREE!
    1. JPA Mini Book
    2. JVM Troubleshooting Guide
    3. JUnit Tutorial for Unit Testing
    4. Java Annotations Tutorial
    5. Java Interview Questions
    and many more ....
    Email address:
    Do you want to know how to develop your skillset to become a Java Rockstar?
    Subscribe to our newsletter to start Rocking right now!
    To get you started we give you our best selling eBooks for FREE!
    1. JPA Mini Book
    2. JVM Troubleshooting Guide
    3. JUnit Tutorial for Unit Testing
    4. Java Annotations Tutorial
    5. Java Interview Questions
    6. Spring Interview Questions
    7. Android UI Design
    and many more ....
    Email address:
    Want to be a DynamoDB Master ?
    Subscribe to our newsletter and download the Amazon DynamoDB Tutorial right now!
    In order to help you master this Amazon NoSQL database service, we have compiled a kick-ass guide with all the major DynamoDB features and use cases! Besides studying them online you may download the eBook in PDF format!
    Email address:
    Programming Interview Coming Up?
    Subscribe to our newsletter and download the Ultimate Multithreading and Concurrency interview questions and answers collection right now!
    In order to get you prepared for your next Programming Interview, we have compiled a huge list of relevant Questions and their respective Answers. Besides studying them online you may download the eBook in PDF format!
    Email address:
    Java Interview Coming Up?
    Subscribe to our newsletter and download the Ultimate Spring interview questions and answers collection right now!
    In order to get you prepared for your next Java Interview, we have compiled a huge list of relevant Questions and their respective Answers. Besides studying them online you may download the eBook in PDF format!
    Email address:
    Java Interview Coming Up?
    Subscribe to our newsletter and download the Ultimate Java interview questions and answers collection right now!
    In order to get you prepared for your next Java Interview, we have compiled a huge list of relevant Questions and their respective Answers. Besides studying them online you may download the eBook in PDF format!
    Email address:
    Want to be a Java NIO Master ?
    Subscribe to our newsletter and download the Java NIO Programming Cookbook right now!
    In order to help you master Java NIO Library, we have compiled a kick-ass guide with all the major Java NIO features and use cases! Besides studying them online you may download the eBook in PDF format!
    Email address:
    Want to be a Drools Master ?
    Subscribe to our newsletter and download the JBoss Drools Cookbook right now!
    In order to help you master Drools Business Rule Management System, we have compiled a kick-ass guide with all the major Drools features and use cases! Besides studying them online you may download the eBook in PDF format!
    Email address:
    Want to be an iText Master ?
    Subscribe to our newsletter and download the iText Tutorial right now!
    In order to help you master iText Library, we have compiled a kick-ass guide with all the major iText features and use cases! Besides studying them online you may download the eBook in PDF format!
    Email address:
    Want to be an Elasticsearch Master ?
    Subscribe to our newsletter and download the Elasticsearch Tutorial right now!
    In order to help you master Elasticsearch search engine, we have compiled a kick-ass guide with all the major Elasticsearch features and use cases! Besides studying them online you may download the eBook in PDF format!
    Email address:
    Want to be a Scala Master ?
    Subscribe to our newsletter and download the Scala Cookbook right now!
    In order to help you master Scala, we have compiled a kick-ass guide with all the basic concepts! Besides studying them online you may download the eBook in PDF format!
    Email address:
    Want to be a JUnit Master ?
    Subscribe to our newsletter and download the JUnit Programming Cookbook right now!
    In order to help you master unit testing with JUnit, we have compiled a kick-ass guide with all the major JUnit features and use cases! Besides studying them online you may download the eBook in PDF format!
    Email address:
    Want to master Amazon Web Services ?
    Subscribe to our newsletter and download the Amazon S3 Tutorial right now!
    In order to help you master the leading Web Services platform, we have compiled a kick-ass guide with all its major features and use cases! Besides studying them online you may download the eBook in PDF format!
    Email address:
    Want to master Spring Framework ?
    Subscribe to our newsletter and download the Spring Framework Cookbook right now!
    In order to help you master the leading and innovative Java framework, we have compiled a kick-ass guide with all its major features and use cases! Besides studying them online you may download the eBook in PDF format!
    Email address:
    Want to master Eclipse IDE ?
    Subscribe to our newsletter and download the Eclipse IDE Handbook right now!
    In order to help you master Eclipse, we have compiled a kick-ass guide with all the basic features of the popular IDE! Besides studying them online you may download the eBook in PDF format!
    Email address:
    Want to master IntelliJ IDEA ?
    Subscribe to our newsletter and download the IntelliJ IDEA Handbook right now!
    In order to help you master IntelliJ IDEA, we have compiled a kick-ass guide with all the basic features of the popular IDE! Besides studying them online you may download the eBook in PDF format!
    Email address:
    Want to master Docker ?
    Subscribe to our newsletter and download the Docker Containerization Cookbook right now!
    In order to help you master Docker, we have compiled a kick-ass guide with all the basic concepts of the Docker container system! Besides studying them online you may download the eBook in PDF format!
    Email address:
    Want to create a kick-ass Android App ?
    Subscribe to our newsletter and download the Android Programming Cookbook right now!
    With this book, you will delve into the fundamentals of Android programming. You will understand user input, views and layouts. Furthermore, you will learn how to communicate over Bluetooth and also leverage Google Maps into your application!
    Email address:
    Want to be a GIT Master ?
    Subscribe to our newsletter and download the GIT Tutorial eBook right now!
    In order to help you master GIT, we have compiled a kick-ass guide with all the basic concepts of the GIT version control system! Besides studying them online you may download the eBook in PDF format!
    Email address:
    Want to be a Hadoop Master ?
    Subscribe to our newsletter and download the Apache Hadoop Cookbook right now!
    In order to help you master Apache Hadoop, we have compiled a kick-ass guide with all the basic concepts of a Hadoop cluster! Besides studying them online you may download the eBook in PDF format!
    Email address:
    Want to master Spring Data ?
    Subscribe to our newsletter and download the Spring Data Ultimate Guide right now!
    In order to help you master Spring Data, we have compiled a kick-ass guide with all the major features and use cases! Besides studying them online you may download the eBook in PDF format!
    Email address:
    Want to create a kick-ass Android App ?
    Subscribe to our newsletter and download the Android UI Design mini-book right now!
    With this book, you will delve into the fundamentals of Android UI design. You will understand user input, views and layouts, as well as adapters and fragments. Furthermore, you will learn how to add multimedia to an app and also leverage themes and styles!
    Email address:
    Want to be a Java 8 Ninja ?
    Subscribe to our newsletter and download the Java 8 Features Ultimate Guide right now!
    In order to get you up to speed with the major Java 8 release, we have compiled a kick-ass guide with all the new features and goodies! Besides studying them online you may download the eBook in PDF format!
    Email address:
    Want to master Java Annotations ?
    Subscribe to our newsletter and download the Java Annotations Ultimate Guide right now!
    In order to help you master the topic of Annotations, we have compiled a kick-ass guide with all the major features and use cases! Besides studying them online you may download the eBook in PDF format!
    Email address:
    Want to be a JUnit Master ?
    Subscribe to our newsletter and download the JUnit Ultimate Guide right now!
    In order to help you master unit testing with JUnit, we have compiled a kick-ass guide with all the major JUnit features and use cases! Besides studying them online you may download the eBook in PDF format!
    Email address:
    Want to master Java Abstraction ?
    Subscribe to our newsletter and download the Abstraction in Java Ultimate Guide right now!
    In order to help you master the topic of Abstraction, we have compiled a kick-ass guide with all the major features and use cases! Besides studying them online you may download the eBook in PDF format!
    Email address:
    Want to master Java Reflection ?
    Subscribe to our newsletter and download the Java Reflection Ultimate Guide right now!
    In order to help you master the topic of Reflection, we have compiled a kick-ass guide with all the major features and use cases! Besides studying them online you may download the eBook in PDF format!
    Email address:
    Want to be a JMeter Master ?
    Subscribe to our newsletter and download the JMeter Ultimate Guide right now!
    In order to help you master load testing with JMeter, we have compiled a kick-ass guide with all the major JMeter features and use cases! Besides studying them online you may download the eBook in PDF format!
    Email address:
    Want to be a Servlets Master ?
    Subscribe to our newsletter and download the Java Servlet Ultimate Guide right now!
    In order to help you master programming with Java Servlets, we have compiled a kick-ass guide with all the major servlet API uses and showcases! Besides studying them online you may download the eBook in PDF format!
    Email address:
    Want to be a JAXB Master ?
    Subscribe to our newsletter and download the JAXB Ultimate Guide right now!
    In order to help you master XML Binding with JAXB, we have compiled a kick-ass guide with all the major JAXB features and use cases! Besides studying them online you may download the eBook in PDF format!
    Email address:
    Want to be a JDBC Master ?
    Subscribe to our newsletter and download the JDBC Ultimate Guide right now!
    In order to help you master database programming with JDBC, we have compiled a kick-ass guide with all the major JDBC features and use cases! Besides studying them online you may download the eBook in PDF format!
    Email address:
    Want to be a JPA Master ?
    Subscribe to our newsletter and download the JPA Ultimate Guide right now!
    In order to help you master programming with JPA, we have compiled a kick-ass guide with all the major JPA features and use cases! Besides studying them online you may download the eBook in PDF format!
    Email address:
    Want to be a Hibernate Master ?
    Subscribe to our newsletter and download the Hibernate Ultimate Guide right now!
    In order to help you master JPA and database programming with Hibernate, we have compiled a kick-ass guide with all the major Hibernate features and use cases! Besides studying them online you may download the eBook in PDF format!
    Email address:
    Want to be a JSF Master ?
    Subscribe to our newsletter and download the JSF 2.0 Programming Cookbook right now!
    In order to get you prepared for your JSF development needs, we have compiled numerous recipes to help you kick-start your projects. Besides reading them online you may download the eBook in PDF format!
    Email address:
    Want to be a Java Master ?
    Subscribe to our newsletter and download the Advanced Java Guide right now!
    In order to help you master the Java programming language, we have compiled a kick-ass guide with all the must-know advanced Java features! Besides studying them online you may download the eBook in PDF format!
    Email address:
    Want to be a Java Master ?
    Subscribe to our newsletter and download the Java Design Patterns right now!
    In order to help you master the Java programming language, we have compiled a kick-ass guide with all the must-know Design Patterns for Java! Besides studying them online you may download the eBook in PDF format!
    Email address:
    Want to be a Hadoop Master ?
    Subscribe to our newsletter and download the Hadoop Tutorial right now!
    In order to help you master Apache Hadoop, we have compiled a kick-ass guide with all the basic concepts of a Hadoop cluster! Besides studying them online you may download the eBook in PDF format!
    Email address:
    Want to be an Elastic Beanstalk Master ?
    Subscribe to our newsletter and download the Amazon Elastic Beanstalk Tutorial right now!
    In order to help you master AWS Elastic Beanstalk, we have compiled a kick-ass guide with all the major Elastic Beanstalk features and use cases! Besides studying them online you may download the eBook in PDF format!
    Email address:
    Amazon Elastic Beanstalk Tutorial
    • Develop your own Amazon Elastic Beanstalk based applications
    • Learn Java Integration and Command Line Interfacing
    • Get your own projects up and running in minimum time
    Want to take your Java skills to the next level?
    Grab our programming books for FREE!
    Here are some of the eBooks you will get:
    • Spring Interview QnA
    • Multithreading & Concurrency QnA
    • JPA Minibook
    • JVM Troubleshooting Guide
    • Advanced Java
    • Java Interview QnA
    • Java Design Patterns
    Insiders are already enjoying weekly updates and complimentary whitepapers!
    Join them now to gain exclusive access to the latest news in the Java world, as well as insights about Android, Scala, Groovy and other related technologies.
    Email address:
    Want to be an ActiveMQ Master ?
    Subscribe to our newsletter and download the Apache ActiveMQ Cookbook right now!
    In order to help you master Apache ActiveMQ JMS, we have compiled a kick-ass guide with all the major ActiveMQ features and use cases! Besides studying them online you may download the eBook in PDF format!
    Email address:
    Apache ActiveMQ Cookbook
    • Explore Apache ActiveMQ Best Practices
    • Learn ActiveMQ Load Balancing and File Transfer
    • Develop your own Apache ActiveMQ projects