Spring MVC Tutorial (3.0)

In this Spring MVC Tutorial (3.0), I am going to give you a start up code base for a Spring MVC 3 based application. If you want to go back and refer to the previous version of Spring MVC then this article will help you. I am assuming that the reader is already aware of Java 5 and Spring basic concepts like annotations, dependency injection etc. Spring 3.0 has extensively used the popular annotation feature of Java 5. As we move ahead in this article, I’ll mention more new things wherever applicable.

It will take following five steps to make everything work on eclipse and tomcat.

  1. Eclipse project set up
  2. Addition of required jars
  3. Creation of required code elements
  4. Running project on tomcat
  5. Testing everything

Let us go through each step in detail.

Spring MVC Tutorial in Detail:

1. Eclipse Project Set Up:

Some of us may think that this is an elementary, but I am mentioning it for those who are new to eclipse. In this step we create a dynamic web project with name SpringMVC3Tutorial. You can use any Eclipse version; most of the recent versions are having these steps similar. I am using Eclipse Galileo for JEE (eclipse-jee-galileo-SR1-win32.zip from eclipse download site). This contains many advanced features, which help in development as well as deployment of application on different servers.

Eclipse menu File -> New -> Project will open this window. Select Dynamic Web Project from it and click on next.

Spring MVC Tutorial - Eclipse Project Setup

It will open following window where you specify the project name as ‘SpringMVC3Tutorial’ and select the server on which you want to deploy application. I am selecting tomcat 6.0 as it is available on my machine. You can configure server as per availability. Click next on following screen.

Now change the source folder from ‘src’ to ‘srcmainjava’. This will help us to keep main and test java classes separate. Later build process becomes easy with build tools like ant and maven. It is also maintainable.

Also on same screen, change the default output folder. This generates the classes at right place with respect to web archive (war). Click next button after that.

Configure web module here. We keep it as ‘srcmainwebapp’.

Clicking on finish button will generate complete project structure for us. It will also generate web.xml which we’ll modify later.

2. Addition of Required Jars:

Let us compare the jars we used in Spring 2.5 and in current version of Spring which is 3.0.

Spring 2.5 Jars:

aopalliance-1.0.jar

commons-logging-1.1.1.jar

servlet-api-2.5.jar

spring-beans-2.5.5.jar

spring-context-2.5.5.jar

spring-context-support-2.5.5.jar

spring-core-2.5.5.jar

spring-web-2.5.5.jar

spring-webmvc-2.5.5.jar

Spring 3.0 Jars:

aopalliance-1.0.jar

commons-logging-1.1.1.jar

servlet-api-2.5.jar

org.springframework.asm-3.0.0.RELEASE.jar

org.springframework.beans-3.0.0.RELEASE.jar

org.springframework.context-3.0.0.RELEASE.jar

org.springframework.context.support-3.0.0.RELEASE.jar

org.springframework.core-3.0.0.RELEASE.jar

org.springframework.expression-3.0.0.RELEASE.jar

org.springframework.web-3.0.0.RELEASE.jar

org.springframework.web.servlet-3.0.0.RELEASE.jar

Jar names in italics are new requirements as compared to previous versions. *asm*.jar is newly added in this stack. Instead of *webmvc*.jar now we have *web.servlet*.jar.

Add these jars to ‘srcmainwebapp WEB-INFlib’ folder.

These jars can be downloaded from Spring’s site or from Maven repository.

3. Creation of Required Code Elements:

Using above two steps, we have created the skeleton we require to write our Spring MVC application. Now we identify the code elements we require to make simple hello world web application work.

HelloWorldController.java

helloworld.jsp

SpringMVC3Tutorial-servlet.xml

Some Changes to web.xml

srcmainjavacommyorgspringmvctutorialwebcontroller HelloWorldController.java:

This is the controller class or what we call ‘C’ in the MVC pattern. If we take a closer look at the code below then we can notice following things.

– It is not extending from any framework class but using annotation @Controller.

– There is no specific method to be used to handle request. We have our business method helloWorld() which is doing the request handling.

– Request processing method helloWorld() is mapped to request pattern /helloWorld (actually it will be ‘http://localhost:8080/SpringMVC3Tutorial/helloWorld.htm’).

There are more annotations around controller, request mapping, and session handling etc. We leave those for more detailed discussion.

<br />package com.myorg.springmvctutorial.web.controller;<br /><br />import org.springframework.stereotype.Controller;<br />import org.springframework.web.bind.annotation.RequestMapping;<br />import org.springframework.web.servlet.ModelAndView;<br /><br />import org.apache.commons.logging.Log;<br />import org.apache.commons.logging.LogFactory;<br /><br />@Controller<br />public class HelloWorldController{<br />	protected final Log logger = LogFactory.getLog(getClass());<br /><br />	@RequestMapping("/helloWorld")<br />	public ModelAndView helloWorld(){<br />		logger.info("Return View");<br />		return new ModelAndView("helloworld.jsp");<br />	}<br />}<br />

srcmainwebapphelloworld.jsp:

This is a simple html page which will confirm that everything is integrated and working fine.

<br />&lt;html&gt;<br />&lt;head&gt;<br />&lt;title&gt;Hello World&lt;/title&gt;<br />&lt;/head&gt;<br />&lt;body&gt;<br />&lt;h1&gt;This is Spring MVC 3 Tutorial&lt;/h1&gt;<br />&lt;p&gt;Our Tutorial is successful.&lt;/p&gt;<br />&lt;/body&gt;<br />&lt;/html&gt;<br />

srcmainwebappWEB-INF SpringMVC3Tutorial-servlet.xml:

This file contains all bean definitions. In our example, it should contain xml like this –

<br />&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br />&lt;beans xmlns="http://www.springframework.org/schema/beans"<br />	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"<br />	xsi:schemaLocation="http://www.springframework.org/schema/beans<br />http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"&gt;<br /><br />	&lt;bean name="/helloworld.htm"<br />		class="com.myorg.springmvctutorial.web.controller.HelloWorldController" /&gt;<br />&lt;/beans&gt;<br />

But we are going to have something different. Instead of explicit definitions like this, we use following two features –

– RequestMapping annotation used in controller class above which maps helloWorld() method to /helloWorld url.

– Autowiring feature of spring.

Also this xml will be validated using newly provided xsds in Spring 3.0.

<br />&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br />&lt;beans xmlns="http://www.springframework.org/schema/beans"<br />	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"<br />	xmlns:context="http://www.springframework.org/schema/context"<br />	xsi:schemaLocation="<br />http://www.springframework.org/schema/beans<br />http://www.springframework.org/schema/beans/spring-beans-3.0.xsd<br />http://www.springframework.org/schema/context<br />http://www.springframework.org/schema/context/spring-context-3.0.xsd"&gt;<br />	&lt;context:component-scan base-package="com.myorg.springmvctutorial.web.controller" /&gt;<br />&lt;/beans&gt;<br />

srcmainwebappWEB-INF web.xml:

It cannot have only the context root definition now. Entire Spring MVC web application runs on DispatcherServlet. We need to define this servlet in web.xml. Here is how we define it.

<br />&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br />&lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"<br />	xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"<br />	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"<br />	id="WebApp_ID" version="2.5"&gt;<br />	&lt;display-name&gt;SpringMVC3Tutorial&lt;/display-name&gt;<br />	&lt;servlet&gt;<br />		&lt;servlet-name&gt;SpringMVC3Tutorial&lt;/servlet-name&gt;<br />		&lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;<br />		&lt;load-on-startup&gt;1&lt;/load-on-startup&gt;<br />	&lt;/servlet&gt;<br />	&lt;servlet-mapping&gt;<br />		&lt;servlet-name&gt;SpringMVC3Tutorial&lt;/servlet-name&gt;<br />		&lt;url-pattern&gt;*.htm&lt;/url-pattern&gt;<br />	&lt;/servlet-mapping&gt;<br />	&lt;welcome-file-list&gt;<br />		&lt;welcome-file&gt;index.htm&lt;/welcome-file&gt;<br />	&lt;/welcome-file-list&gt;<br />&lt;/web-app&gt;<br />

4. Running Project on Tomcat:

You can choose what you like from following options.

– Use tomcat integration with eclipse and deploy using right click Run -> Run on Server option.

– Export project as a war using File -> Export menu option and copy generated war file in webapps directory of tomcat.

– Use any build tool like ant, maven to generate the war file and copy it to webapps directory on tomcat.

5. Testing Everything:

To see if everything is integrated and working fine in this Spring MVC Tutorial, access this url http://localhost:8080/SpringMVC3Tutorial/helloWorld.htm in browser and we see following page displayed.

References:

Spring MVC 3.0 Documentation

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

20 thoughts on “Spring MVC Tutorial (3.0)

  • December 29, 2009 at 4:25 pm
    Permalink

    Im trying to develop a Spring MVC application using the RC2 version of spring. I am able to set up my controller and use a annotated method as follows:

    @RequestMapping("/Administration")
    public String test(){
    System.out.println("IN ADMINISTRATION");
    return "test";
    }

    Everything works fine, when i go to http://localhost:8080/myApp/Administration I get view the “test” view. However when I use

    @RequestMapping("/Administration/{id}")
    public String test(@PathVariable String id, Model model){
    System.out.println("IN ADMINISTRATION");
    return "test";
    }

    It does not get into the method when i go to http://localhost:8080/myApp/Administration/2

    If you have any advice I would greatly appreciate it. This is the contents of my dispatcher-servlet.xml file:

    Reply
  • December 30, 2009 at 2:33 pm
    Permalink

    Sorry for some reason my dispatcher-servlet.xml file wasn’t included. Anyways I worked through my problem and found that if I was to change my url mapping to / it fixed my mapping problem. However this caused all of my static files such as css, images and javascript to not be found.

    In order to fix this I have created a mapping for each sub directory url/Administration/* This is my first time working with java for the web and to be honest I’m really not that impressed by all of the configuration and dependent files that are needed to set up a basic mvc framework. If you have any other advice to make my life easier I would appreciate it. Thank you for writing this great tutorial!

    Reply
  • December 30, 2009 at 2:38 pm
    Permalink

    for some reason my code isn’t showing up heres another try:

    “/”

    this URL pattern allows me to create mappings to controllers such as http://localhost/Site/Administration/user/2

    however it doesn’t allow me to map to static files such as javascript, images, and css.

    in order to fix this I had to use:

    “/Administration/*”

    along with “/*” to access static content

    Reply
  • December 31, 2009 at 4:06 pm
    Permalink

    Hi,

    I am new to spring annotations and i tried to setup the project as described and when i run my URL i am getting the following exception:

    HTTP Status 404 – /SpringMVC3Tutorial/helloworld.jsp

    type Status report

    message /SpringMVC3Tutorial/helloworld.jsp

    description The requested resource (/SpringMVC3Tutorial/helloworld.jsp) is not available.

    thanks

    Reply
    • January 4, 2010 at 10:53 am
      Permalink

      Hi,
      I think there is some problem with the project structure. Please check if it is as required.

      Reply
  • January 10, 2010 at 10:54 am
    Permalink

    hi i have the same problem as joe kolba

    i have prepare a Administration/user/{id} requestmapping at the controller which return a String which is the page name
    i have even set up the viewResolver at the app-servlet.xml
    but after running http://localhost/Site/Administration/user/2,

    it successfully returns me to the page and display the id (which is 2) but all my stylesheet and image is gone. any clue?

    Reply
  • January 15, 2010 at 3:37 pm
    Permalink

    I fall at the first hurdle with these errors on the HelloWorldController:

    The project was not built since its build path is incomplete. Cannot find the class file for java.lang.Object. Fix the build path then try building this project

    The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files

    Reply
    • January 18, 2010 at 5:40 am
      Permalink

      Please add JRE to class path.

      Reply
  • April 30, 2010 at 1:43 pm
    Permalink

    thx veru good tutorial for starting

    Reply
  • November 6, 2010 at 7:23 am
    Permalink

    Hi,
    I am getting below exception, looks like some problem with ‘component-scan’ context element. I have not missed any jars to be attached…
    org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 15 in XML document from ServletContext resource [/WEB-INF/SpringMVC3Tutorial-servlet.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element ‘context:component-scan’.
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:378)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:316)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:284)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
    at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
    at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:93)
    at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:126)
    at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:419)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:349)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:427)
    at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:341)
    at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:307)
    at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
    at javax.servlet.GenericServlet.init(GenericServlet.java:212)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1048)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:950)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4122)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4421)
    at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:312)
    at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java:144)
    at org.jboss.web.deployers.AbstractWarDeployment.start(AbstractWarDeployment.java:461)
    at org.jboss.web.deployers.WebModule.startModule(WebModule.java:118)
    at org.jboss.web.deployers.WebModule.start(WebModule.java:97)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)
    at org.jboss.system.microcontainer.ServiceProxy.invoke(ServiceProxy.java:206)
    at $Proxy36.start(Unknown Source)
    at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:42)
    at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:37)
    at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
    at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
    at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
    at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
    at org.jboss.system.microcontainer.ServiceControllerContext.install(ServiceControllerContext.java:286)
    at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1598)
    at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
    at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1062)
    at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
    at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
    at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
    at org.jboss.system.ServiceController.doChange(ServiceController.java:688)
    at org.jboss.system.ServiceController.start(ServiceController.java:460)
    at org.jboss.system.deployers.ServiceDeployer.start(ServiceDeployer.java:163)
    at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:99)
    at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:46)
    at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)
    at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
    at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
    at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
    at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
    at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178)
    at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
    at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
    at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1598)
    at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
    at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1062)
    at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
    at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
    at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
    at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
    at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:698)
    at org.jboss.system.server.profileservice.hotdeploy.HDScanner.scan(HDScanner.java:290)
    at org.jboss.system.server.profileservice.hotdeploy.HDScanner.run(HDScanner.java:221)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:417)
    at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:280)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:135)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:65)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:146)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:170)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:651)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:676)
    at java.lang.Thread.run(Thread.java:613)
    Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element ‘context:component-scan’.
    at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator.emptyElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
    at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:370)
    … 80 more

    Reply
  • November 30, 2010 at 8:18 pm
    Permalink

    I was having the same problem as Joe Kolba and Stanley… remapping servlet to catch everything (“/”) would cause css, js, etc to stop displaying.

    It took some tinkering, but I think I found what works…

    /pages/*

    @RequestMapping(value=”helloWorldPage/{id}”, method=RequestMethod.GET)

    url: http://localhost:8080/youcontextroot/pages/helloWorldPage/123

    Reply
  • December 3, 2010 at 2:24 pm
    Permalink

    I was having the same problem as Joe Kolba and Stanley… remapping servlet to catch everything (“/”) would cause css, js, etc to stop displaying.

    It took some tinkering, but I think I found what works…

    /pages/*

    @RequestMapping(value=”helloWorld/{id}”, method=RequestMethod.GET)

    url: http://localhost:8080/yourcontextroot/pages/helloWorld/123

    Reply
  • December 22, 2010 at 6:30 am
    Permalink

    Hi,

    I am new to spring and its helpful.

    However, I found some typo mistake in this tutorial.

    In SpringMVC3Tutorial-servlet.xml:

    However in HelloWorldController.java

    @RequestMapping(“/helloWorld”)

    ‘w’ is written in small case in xml while in java ‘w’ is written in upper case.

    I hope, you understand what I mean.

    Reply
  • February 15, 2012 at 3:35 pm
    Permalink

    This tutorial is very easy to understand. Thanks a lot…

    Reply
  • February 24, 2012 at 2:28 am
    Permalink

    Good and easy to understand. It is working fine.

    Reply
  • Pingback: Takie różne informacje dla deweloperów | Wiadomości o technologiach IT

Leave a Reply

Your email address will not be published. Required fields are marked *

Email
Print