Spring-Spring MVCNo Comments

In this tutorial, we show you a Spring 3 MVC hello world example, using Maven build tool.

Technologies used :

  1. Spring 3.2.13.RELEASE
  2. Maven 3
  3. JDK 1.7
  4. Boostrap 3
  • Maven

A pom.xml template to quick start a Spring MVC project, it defines Spring 3 dependencies, an embedded Jetty container and Eclipse workspace configuration.

pom.xml : 

  • Controller & Mapping

The @RequestMapping has been available since 2.5, but now enhanced to support REST style URLs.

HelloController.java : 

  • JSP Views

A JSP page to display the value, and include bootstrap css and js.

html4strict : 

  •  Spring XML Configuration

  • Enable component scanning, view resolver and resource mapping.
spring-web-servlet.xml : 

  • Declares a DispatcherServlet in web.xml. If the Spring XML configuration file is NOT specified, Spring will look for the {servlet-name}-servlet.xml.

In this example, Spring will look for the spring-web-servlet.xml file.

web.xml : 

You can define a Spring XML file via contextConfigLocation.

web.xml  : 

  • Demo

That’s it , you can now access to below links to see result.

URL : http://localhost:8080/springmvc

URL : http://localhost:8080/springmvc/hello/javasail

Thanks you for reading and see you in my next post about SpringMVC.





Be the first to post a comment.

Add a comment