MVC Simplifications in Spring 3.0 |
|

As Juergen and Arjen have mentioned, Java developers everywhere have a smooth upgrade with Spring 3.0. Now that Spring 3 is out, I'd like to take you through some of the new MVC features you may not know about. I hope you find these features useful and can start putting them to work in your web applications immediately.
This is also the start of a series on "Spring 3 Simplifications", so expect more posts like these in the coming days and weeks.
Configuration Simplification
Spring 3 introduces a mvc namespace that greatly simplifies Spring MVC setup. Along with other enhancements, it has never been easier to get Spring web applications up and running. This can be illustrated by the mvc-basic sample, which I will now walk you through.
mvc-basic has been designed to illustrate a basic set of Spring MVC features. The project is available at our spring-samples SVN repository, is buildable with Maven, and is importable into Eclipse. Start your review with web.xml and notice the configuration there. Notably, a DispatcherServlet is configured with a single master Spring configuration file that initializes all other application components. The DispatcherServlet is configured as the default servlet for the application (mapped to "/"), allowing for clean, REST-ful URLs.
Inside the master servlet-context.xml, you'll find a typical setup. On the first line, component scanning has been turned on to discover application components from the classpath. On the next line, you'll find the first new Spring MVC 3 feature in action:
<!-- Configures the @Controller programming model --> <mvc:annotation-driven />
This tag registers the HandlerMapping and HandlerAdapter required to dispatch requests to your @Controllers. In addition, it applies sensible defaults based on what is present in your classpath. Such defaults include:
- Using the Spring 3 Type ConversionService as a simpler and more robust alternative to JavaBeans PropertyEditors
- Support for formatting Number fields with @NumberFormat
- Support for formatting Date, Calendar, and Joda Time fields with @DateTimeFormat, if Joda Time is on the classpath
- Support for validating @Controller inputs with @Valid, if a JSR-303 Provider is on the classpath
- Support for reading and writing XML, if JAXB is on the classpath
- Support for reading and writing JSON, if Jackson is on the classpath
Pretty cool, huh?
Moving on, the next line demonstrates another new feature:
<!-- Forwards requests to the "/" resource to the "welcome" view --> <mvc:view-controller path="/" view-name="welcome" />
Behind the scenes, mvc:view-controller registers a ParameterizableViewController that selects a view for rendering. In this case, when "/" is requested, the welcome view is rendered. The actual view template is a .jsp resolved inside the /WEB-INF/views directory.
Moving on, the next line shows yet another new feature:
<!-- Configures Handler Interceptors -->
<mvc:interceptors>
<!-- Changes the locale when a 'locale' request parameter is sent; e.g. /?locale=de -->
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" />
</mvc:interceptors>
The mvc:interceptors tag allows you to register HandlerInterceptors to apply to all controllers. Previously, to do this you had to explicitly register such interceptors with each HandlerMapping bean, which was repetitive. Also note this tag now lets you restrict which URL paths certain interceptors apply to.
Moving on, the next line hightlights a new feature added in version 3.0.4:
<!-- Handles GET requests for /resources/** by efficiently serving static content in the ${webappRoot}/resources dir -->
<mvc:resources mapping="/resources/**" location="/resources/" />
The mvc:resources tag lets you configure a handler for static resources, such as css and javascript files. In this case, requests for /resources/** are mapped to files inside the /resources directory.
Putting things in motion, if you deploy the sample you should see the welcome view render:

Feel free to activate the different language links to have the LocaleChangeInterceptor switch the user locale.
Data Binding Simplification
The next set of new features I'll illustrate pertain to @Controller binding and validation. As I blogged about a few weeks ago, there is a lot new in this area.
In the sample, if you activate the @Controller Example link the following form should render:

From there, if you change the locale you should see internationalized field formatting kick in. For example, switching from en to de would cause the Renewal Date 12/21/10 to be formatted 21.12.10. This behavior and the form's validation rules are driven by model annotations:
public class Account {
@NotNull
@Size(min=1, max=25)
private String name;
@NotNull
@NumberFormat(style=Style.CURRENCY)
private BigDecimal balance = new BigDecimal("1000");
@NotNull
@NumberFormat(style=Style.PERCENT)
private BigDecimal equityAllocation = new BigDecimal(".60");
@DateTimeFormat(style="S-")
@Future
private Date renewalDate = new Date(new Date().getTime() + 31536000000L);
}
Form submit is handled by the following AccountController method:
@RequestMapping(method=RequestMethod.POST)
public String create(@Valid Account account, BindingResult result) {
if (result.hasErrors()) {
return "account/createForm";
}
this.accounts.put(account.assignId(), account);
return "redirect:/account/" + account.getId();
}
This method is called after binding and validation, where validation of the Account input is triggered by the @Valid annotation. If there are any validation errors, the createForm will be re-rendered, else the Account will be saved and the user will be redirected; e.g. to http://localhost:8080/mvc-basic/account/1.
For an illustration of another cool new feature, try requesting an account that does not exist; e.g. /account/99.
Summary
Spring 3 is a great release containing numerous new features and simplifications across many exciting areas. I hope you found this post on some of the new Spring MVC enhancements useful. As I mentioned at the top, expect more to come in the "Spring 3 Simplifications" series, where we will continue to show new and interesting things you can do with the latest version of the framework.
Happy Holidays!
Similar Posts
- Spring 3 Type Conversion and Validation
- Integrating Spring MVC with jQuery for validation rules
- Ajax Simplifications in Spring 3.0
- Using a Hybrid Annotations & XML Approach for Request Mapping in Spring MVC
- New application layering and persistence choices in Spring Roo 1.2





Jose Noheda says:
Added on December 21st, 2009 at 5:11 amEverything looks nice. My only complain is that you always showcase the same example time and again. What about something more interesting like a content negotiating JSON view with an AJAX submit? All these page oriented examples look old and boring to me (though the features are great additions)
Keith Donald (blog author) says:
Added on December 21st, 2009 at 7:52 amHi Jose
For the first article in the "Spring 3 Simplifications" series, my goal was to focus on core MVC features you would use regardless if you were developing a Ajax oriented front-end or something more "boring". Many of the upcoming articles will focus on more specific areas and absolutely one of them will be Ajax/JSON.
Martin Flower says:
Added on December 21st, 2009 at 10:07 amThanks for the posting – I'm working my way through the example. Working with latest STS 2.3.0 Two points so far
1. I cannot add the project to Tomcat 5.5 : " Tomcat version 5.5 only supports J2EE 1.2, 1.3, and 1.4 Web modules". I cannot deselect dynamic web modules in the facets, or change the version. It does work with Tomcat 6.0. Our current Company standard is 5.5 [Java 6] – are we forced to upgrade ?
2. I have the following error message at the bottom of my STS screen
[Modules] the Web module at the followign location cannot be found: org.springframework.samples.mvc.basic
If necessary I'll post some more as I go along.
Michael Ebert says:
Added on December 21st, 2009 at 10:15 am"For an illustration of another cool new feature, try requesting an account that does not exist; e.g. /account/99."
What should be happening here? ResourceException is thrown but the browser result is a common tomcat 404. Under the hood, one can find out that the DispatcherServlet tries to handle the Exception through ResponseStatusExceptionResolver. Is this the cool new feature? How can I attach a error view with the 404 status code?
Andrea Del Bene says:
Added on December 21st, 2009 at 10:37 amHi Keith!
I really like this new set of annotations/schemas which simplifies MVC programming (validation is very "Grails-style" now
).
Anyway I'd like to know if SpringSource is planning to extend MVC to use different kinds of presentation technology (other then web pages).
It' would be nice to have a common MVC framework with a pluggable presentation technology, so you can write once Model and Controller and use them with different presentation technologies (JSP, Swing, ecc…).
Thank you and bye bye!
David Hassler says:
Added on December 21st, 2009 at 11:17 amA helpful hint…
If you want to remove the stack traces when a field type conversion fails (i.e. putting "foo" in the balance field), BindingResult registers a DefaultMessageCodesResolver which allows you to put entries such as
typeMismatch.account.balance=Balance format error
in messages.properties. As an added bonus, the ReloadableResourceBundleMessageSource will add the messages with out an app restart.
jonash says:
Added on December 21st, 2009 at 12:47 pmnice! every release is a major improvement. i would really appreciate example on how to use JSON
Keith Donald says:
Added on December 21st, 2009 at 1:01 pmMartin,
Spring 3 runs perfectly fine on J2EE 1.4 servers (e.g. Tomcat 5.5 with Servlet 2.4). Just this mvc-basic sample's Eclipse WTP settings are configured with the 2.5 jst.web facet (the web.xml of the sample also has version="2.5"). I did this simply because Servlet 2.5 / Tomcat 6 is what we generally recommend these days.
I do think we should make at least one of our Spring 3 samples Servlet 2.4 compatible as well and have noted that.
I am not sure what could be causing that second error you're seeing. The mvc-basic app is deploying fine for me in my copy of STS 2.3.0. Note: to install Tomcat 6.0 in STS I clicked the SpringSource Dashboard icon on the toolbar, then accessed the "Configuration" tab in the Dashboard Editor, then activated the "Install Apache Tomcat v6.0" link. Deploying to that server, as well as to the SpringSource tc Server, worked like a charm without any additional work.
I hope you've been able to get the sample running smoothly in STS in the end. Let me know if something could be made easier still.
Keith
Keith Donald (blog author) says:
Added on December 21st, 2009 at 1:17 pmMichael,
Sending the 404 is the expected behavior there. This is indeed driven by the ResourceNotFoundException, which you'll notice is annotated with @ResponseStatus. Yes, the auto-mapping of exceptions to HTTP error statuses is the "cool feature" I was referring to.
To render a specific view instead, you'll need to define a custom @Controller @ExceptionHandler method for your ResourceNotFoundException. That method could then return a specific view name as a String.
Keith
Martin Flower says:
Added on December 22nd, 2009 at 4:34 amHi Keith – thanks for the 2.5 information. What I'm interested in is what I need to change in order to make this 2.4 compatible. Can it be done ? Thanks. Martin.
James Hoare says:
Added on December 22nd, 2009 at 5:59 amKeith, firstly thanks for the post and examples. I am looking forward to some more in particular examples for the @Scheduled and @Async support.
However, I tried to connect my exception to a customer controller as you suggested in your previous post…
"To render a specific view instead, you'll need to define a custom @Controller @ExceptionHandler method for your ResourceNotFoundException. That method could then return a specific view name as a String."
I have tried this but my Controllers method never gets invoked, its annotated with the following?
@ExceptionHandler(ResourceNotFoundException.class)
public String notFoundException(Throwable t)
{
return "resourceNotFound";
}
What am I doing wrong, as I would like to render my own view rather than sending the 404 in the exception resolver.
Thanks
Donny says:
Added on December 22nd, 2009 at 8:29 amHi Keith,
Any plan to implement resource-per-controller like Struts 2? I would love to see more pluggable MVC framework that manage resource like javascript, css, resource bundle, theme conf inside particular package.
Regards,
Donny
Erik Weibust says:
Added on December 22nd, 2009 at 12:12 pmKeith,
Are there any plans to re-write the Spring MVC step-by-step tutorial, or will you just be releasing these short individual blog posts (which are helpful)? I'd love to see the step-by-step tutorial updated if I can vote for it.
Thanks…
Erik
Erik Weibust says:
Added on December 22nd, 2009 at 12:22 pmJames Hoare,
Your custom @Controller @ExceptionHandler method is good. I think all you are missing is adding a jsp to the views dir with the name of the string you are returning in your method.
I copied your method to my AccountController and created a resourceNotFound.jsp in my views directory and that new jsp was served when I requested an account that doesn't exist.
Erik
SMiGL says:
Added on December 22nd, 2009 at 2:17 pmSimple and helpful
Keith Donald (blog author) says:
Added on December 22nd, 2009 at 8:27 pmErik,
Thanks for the tip re: @ExceptionHandler.
Yes, in addition to this blog series, we are working on a revised Spring step-by-step tutorial, several articles, and several new reference applications. As you can tell, there is a lot happening now and several other projects such as Spring Security and Spring Roo are about to go GA with their next major version. I anticipate the revised tutorial will publish shortly after some of these other releases.
Merry Christmas to you and your family!
Keith
齐冀(China) says:
Added on December 28th, 2009 at 8:54 amHi:
I use json as view,but in the binding result i can't modify the default message.I can't get the message throught error code.How can i do this problem?Thanks
Anindya Mukherjee says:
Added on January 1st, 2010 at 2:20 pmNice article really.. we are currently using Spring 2.5 , hopefully will upgrade to 3.0 soon ..
Bojan says:
Added on January 3rd, 2010 at 11:27 amI have comment regarding whole Spring 3.0 MVC concept, it reminds me on Struts2 actions. And Struts2 can be very confusing if it's not used properly. For example, I have seen many actions containing a few thousands lines of code – written by inexperienced developers. For example there were many actions methods, a lots of lists which were representing Model Attributes (instead one "ReferenceData" map), lots of properties for submitting request parameters, etc… Whole subsystem was placed in that action. Spring 2.X didn't allow that, you couldn't do such thing with SimpleFormController. I think Spring 2.X was forcing developer to write code properly. But I am afraid this Struts2 scenario can be achieved in Spring3.0. (of course if it's used by mentioned developers) .
And there is one more thing I don't like, that's @RequestMapping annotation. I don't like the fact that actions urls are scattered across many java (controller) files. For example if I wanted to find which controller will handle request for some url, I had to search through all my controllers to find wanted controller. (What if I have 50 controllers??). I think this should be placed on centralized place, something like Spring 2.5 style. Maybe this can be achieved (I found also a blog about this: http://blog.springsource.com/2008/03/23/using-a-hybrid-annotations-xml-approach-for-request-mapping-in-spring-mvc/ but I don't know fd RequestMapping annotation can be replaced using this pattern)
Regards! Boyan!
Kenny Macleod says:
Added on January 4th, 2010 at 5:01 amThe annotation mapping and handler adapters are registered by default in Spring 2.5 and 3.0, so what is the value added by having ?
Keith Donald (blog author) says:
Added on January 4th, 2010 at 11:57 amBojan,
I agree the Spring MVC POJO @Controller model provides less structure compared to the older FormController hierarchy. The main benefits of the POJO model are increased flexibility, reduced configuration, and easier testability. Indeed, developers should be disciplined in their @Controller design. I generally recommend structuring @Controllers by the logical resources they control access to; e.g. AccountController, for working with Accounts. I find such functional or "resource-oriented" design to be quite effective.
Using annotations to define request mappings does decentralize the mapping metadata. I find this to be a benefit as it promotes more modular applications. I can still get a centralized view of the mapping metadata by using a tool such as the SpringSource Tool Suite's @Controller outline view.
Best regards,
Keith
Keith Donald (blog author) says:
Added on January 4th, 2010 at 12:08 pmKenny,
You are correct – if you do not install any HandlerAdapters yourself, the DispatcherServlet will install a default set for you, which includes support for invoking @Controllers (AnnotationMethodHandlerAdapter). However, the DispatcherServlet itself is limited in its ability is to configure those default implementations via dependency injection (it actually instantiates those default strategies by reflection from reading a properties file in order not to depend on their implementation classes directly). Use of the mvc:annotation-driven tag allows us not only to register such HandlerAdapter beans but also configure them from higher-level user settings. It also makes it easy for the user to register further custom HandlerAdapters (such as for plugging in Spring Web Flow's FlowHandlerAdapter), since once you need that the default set doesn't apply any longer anyway.
Best regards,
Keith
Newbie Doobie says:
Added on January 6th, 2010 at 7:59 pmCould really use that new step-by-step tutorial about now.
Thanks -ND.
lucian demis says:
Added on January 15th, 2010 at 6:37 amHello,
I'm using the new simplified spring 3 mvc configuration like here that means no ContextLoaderListener in web.xml but when I'm adding the basic spring security 3.0 config I receive the following error:
java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
org.springframework.web.filter.DelegatingFilterPro xy.doFilter(DelegatingFilterProxy.java:159)
What is the bet way to configure a spring3 MVC app and spring security 3?
Thanks
Daniel Alexiuc says:
Added on January 18th, 2010 at 7:41 pmJust one small criticism…
Please don't call them REST-ful URLs. There is enough confusion and uncertainty about REST already on the internet – and these URLs have nothing to do with REST. Don't call them RESTful "style" URLs either, it is too confusing. You are sort of implying that you can have a RESTful architecture simply by applying a URL Rewrite filter – and nothing could be further from the truth.
Just call them pretty urls or nice urls.
Rainer Rettweiler says:
Added on February 3rd, 2010 at 7:30 amI tried to get this sample running on GAE/J. It runs fine within googles eclipse plugin, but deployed on GAE I still get an exception, when calling "/account".
Has anyone solved this already?
Jeff Holt says:
Added on February 19th, 2010 at 12:43 pmHi, we are experimenting with Spring 3.0 MVC and are having issues with Apache being in front of our WebLogic server.
If we call our view like this:
http://localhost:7001/myapp/welcome/localhost with port
The Controller works as expected.
If we call our view like this:
http://localhost/myapp/welcome/the right way
We get 404.
We know that Apache is forwarding the request as expected by looking through our logs and the fact that we can access other .jsp pages like this:
http://localhost/myapp/other.jsp
It feels like the DispatcherServlet is not being called correctly, or there is some kind of rewrite problem.
Any experience with this kind of problem?
Thanx!
Jeff Holt says:
Added on February 20th, 2010 at 11:56 amThere was a redirection issue, which after posting here, magically revealed itself, as it should once I went public with my confusion.
swell says:
Added on April 15th, 2010 at 10:09 amHi, How can I download the spring-samples for study from
https://src.springframework.org/svn/spring-samples/
thanks a lot.
mhellwig says:
Added on April 17th, 2010 at 5:19 amgot a 404 when pressing "submit"?
try adding an action to the form in createForm.jsp:
worked for me
Dmitriy says:
Added on April 23rd, 2010 at 3:47 amswell,
First of all you must install an appropriated for your IDE subversion plug-in from http://www.tigris.org/
Then you can checkout any projects from SVN
john says:
Added on April 23rd, 2010 at 5:16 pmI am student. How can I download the spring-samples for study from
https://src.springframework.org/svn/spring-samples/
bernwey says:
Added on April 29th, 2010 at 10:05 pmThere's no link to download these samples.What a pity!
LiNk says:
Added on April 30th, 2010 at 1:52 pmWhat was the redirection issue?
sunil says:
Added on May 21st, 2010 at 8:17 amThank you for your blog, much appreciated.
I've installed the mvc-basic app, and am running on Tomcat 6 in MyEcipse (MacOSX).
The welcome page loads fine, but when I try the @Controller Example, I get a 404:
org.springframework.web.servlet.PageNotFound – No mapping found for HTTP request with URI [/mvc-basic/app/account] in DispatcherServlet with name 'Spring MVC Dispatcher Servlet'.
Not quite sure where I have gone wrong.
cheers
Luc Pezet says:
Added on June 14th, 2010 at 3:54 pmHi Keith!
Do you have any information to share regarding the "deprecation" of Controller hierarchy?
By information, I mean the reasoning.
I read multiple posts (including yours) where it's mentioned that annotation is an "upgrade" (ref. http://blog.springsource.com/2009/12/16/spring-framework-3-0-goes-ga/ with the "upgrade guide") but no reasoning whatsoever. (or did I miss one?)
I personally don't think annotations are an upgrade…on the contrary.
Do you have any feedback on people/companies using annotations in production (along with details on samples)?
Is the plan to delete those Controller classes in next release?
Thanks for your help,
Luc.
Jieyan Fan says:
Added on June 17th, 2010 at 8:42 pmI was playing around the mvc-basic sample downloaded from https://src.springframework.org/svn/spring-samples/mvc-basic/trunk/
I ran mvn clean install to create mvc-basic.war, and copied it to tomcat's webapps directory. I'm using Tomcat 6 in RHEL 4.
When I visit http://localhost/mvc-basic/, I got 404 returned. Check the tomcat log, it says something like
2010-06-17 18:41:27,642 WARN [org.springframework.web.servlet.PageNotFound] No mapping found for HTTP request with URI [/mvc-basic/] in DispatcherServlet with name 'Spring MVC Dispatcher Servlet'
Anyone knows how to fix?
Keith Donald (blog author) says:
Added on June 19th, 2010 at 10:24 amJieyan and Sunil:
I haven't been able to reproduce your issue. As I was trying, I went ahead and upgraded mvc-basic to the latest version of Spring Framework (3.0.3). Give the latest a try for yourself.
Best,
Keith
Thal Ritha says:
Added on June 26th, 2010 at 10:39 amThanks very much for the sample.
Only question so far is that when I run mvn tomcat:redeploy it looks for mvc-basic-1.0.0-SNAPSHOT.war rather than mvc-basic.war that the install actually builds. I can copy the war into Tomcat ok. Just wondering what change I need to make to get redeploy to look for the correct war. Sorry for newbie question.
Reddy says:
Added on July 3rd, 2010 at 10:26 pmCan you let me know where can i download the https://src.springframework.org/svn/spring-samples/mvc-basic/trunk/ zip file ?
Declan Butler says:
Added on July 9th, 2010 at 9:25 ammvc-basic.war
http://www.box.net/shared/aqfxkrpbz7
sheikshavali says:
Added on July 18th, 2010 at 8:46 amHi Keith Donald ,
Thanks for sharing.
This blog proved very helpful.
Gerald says:
Added on July 23rd, 2010 at 2:52 amHi. . .can I share my problem here?? I'm noob in spring mvc. .I'm using hibernate to connect to mysql database, . .well I've manage the connection, just like this example creating an account of users and save it to database. . .but I'm having a kind of this error . .
org.springframework.web.util.NestedServletException:
Request processing failed; nested exception is java.lang.IllegalStateException:
Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)
by the way I'm using SpringSource Tool Suite
Can anyone help?
Thanx. . .
JK says:
Added on August 4th, 2010 at 3:00 amThanks for the posting, the information is very useful.
Clicked the locale "gb",but it can't refer the "messages_gb.properties".
I tried different value, finally found <a href="?locale=gb_gb" can work.
However, don't know what is the meaning for gb_gb or why?
JK
Alex says:
Added on August 4th, 2010 at 2:58 pmDo I still have to create dispatcher-servlet.xml if I'm using the 'mvc' namespace?
I'm asking because I've tried to use the namespace and removed dispatcher-servlet.xml completely – eventually nothing is mapped to any one of the controllers.
Thanks,
Hidayath Basha says:
Added on August 11th, 2010 at 11:09 pmGuys… Whoever wants to download the code do an SVN checkout from https://src.springframework.org/svn/spring-samples/mvc-basic/trunk/
Henrique says:
Added on September 2nd, 2010 at 5:07 amHello – I'm new to Spring and I'm unfortunately not able to run this Sample Spring app in my environment.
I'm using Tomcat 6.0.29 and the Maven/Source code provided in the Samples repository. I seem to have an issue with JSTL 1.2. The following is the exception thrown.
org.apache.jasper.JasperException: Unable to read TLD "META-INF/c.tld" from JAR file "file:/C:/apache-tomcat/apache-tomcat-6.0.29/wtpwebapps/mvc-basic/WEB-INF/lib/jstl-1.2.jar": org.apache.jasper.JasperException: Failed to load or instantiate TagLibraryValidator class: org.apache.taglibs.standard.tlv.JstlCoreTLV
Validated the JAR file, and it does contain the JstlCoreTLV class. Copyied the jstl-1.2.jar to the Tomcat /lib (to be sure), and issue continues.
Hopefully someone can help me on this?
LogixPlayer says:
Added on September 18th, 2010 at 4:05 pmHi Keith and everybody else…I am in all sorts of trouble…using this new mvc tag for Validations.
I have a spring 3 mvc web app. I would like to take advantage of Spring 3 validations with annontations. The second I put this tag in: I keep getting a 404 error. This is driving me nuts. I was using Tuckey URL to manage all my URL clean restful mappings with Tiles as my view technology.
The error is basically the one that says: No mapping found for HTTP request…
I noticed that if I comment out my base URL rewrite rule in Tuckey,
/
/pf/welcome
and use this mvc tag:
I get forward to my HomePage BUT there is a difference, when I use Tuckey, I get forward to my controller, when I use mvc:view-controller path="/" I get forward to the view as the command suggests. My controller does a whole bunch of initializations before rendering…..which is a good thing….
basically I want to use Spring 3 validations for my web app through annotations BUT I am getting mapping excepts.
I have also posted on Spring and StackOverFlow…
can someone please give me a hand….
http://stackoverflow.com/questions/3714709/mvcannotation-driven-spring-mvc-3-and-tuckey-url-filter
http://forum.springsource.org/showthread.php?t=95172
This is a pretty serious issue and my development has been absolutely halted….please reach out thanks!!
Sam says:
Added on November 4th, 2010 at 11:39 amThanks for this tutorial. I'd like to check out the mvn-basic repository but I'm having trouble connecting (could not connect to server (https://src.springframework.org))
Do you allow your readers to check out this repo? It would certainly seem silly to make it a repository if nobody can check it out. Perhaps it's just a problem with svn on my end.
José says:
Added on November 11th, 2010 at 12:51 pmAlso getting the following error
org.apache.jasper.JasperException: Unable to read TLD "META-INF/c.tld" from JAR file "file:/Development/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/mvc-basic/WEB-INF/lib/jstl-1.2.jar": org.apache.jasper.JasperException: Failed to load or instantiate TagLibraryValidator class: org.apache.taglibs.standard.tlv.JstlCoreTLV
paul says:
Added on November 19th, 2010 at 3:58 amawesome! i wanna share too a link i found in the web. this uses the latest release from spring-framework-3.0.5.. it is a tutorial on creating web apps using spring mvc.
http://www.adobocode.com/spring/a-spring-web-mvc-tutorial
hope you find it okay!
Brian says:
Added on December 12th, 2010 at 11:08 pmHey Keith,
Can you shed some light on the progress of this bug with relationship to this post:
https://jira.springframework.org/browse/SPR-6437
It appears that there is still no way to validate a form object field unless there is a direct correlation to an HTML form field using just @Valid and a JSR-303 provider on the class path. I have a post over on the forums that details some of the problem further:
http://forum.springsource.org/showthread.php?t=99588
Thanks for any assistance.
Inácio Ferrarini says:
Added on February 13th, 2011 at 5:28 pmHi there!
When I add a collection to the form, in order to render it as a form:select, the items disappear when an validation error happens. Would you have any idea how could I solve that?
Thanks in advance,
Inácio.
jrey says:
Added on February 19th, 2011 at 12:49 pmThe link to the mvc-basic project is not working:
https://src.springframework.org/svn/spring-samples/mvc-basic/trunk/
http://www.orlandoflorida.net/forums/members/scottwoods718.html says:
Added on April 9th, 2011 at 8:21 pmGreat post. I was checking constantly this blog and I am impressed! Extremely useful information specifically the last part
I care for such info a lot. I was seeking this certain information for a very long time. Thank you and good luck.
Kamal says:
Added on April 10th, 2011 at 1:31 pmHi,
I am new here,I did struts1.8,
I am here to learn spring, I will appreciate if you can bear with me and give me some helps.
1)Where to learn spring MVC as a biginner ?
2)I did not understand how when you run this web application it knows about welcome.jsp file and its located in WEB-INF\views folder ?
3)The same thing here,in the welcome.jsp we have the link :
@Controller Example
what is account in this link ?
when you clik in this account it goes to :
http://localhost:8083/mvc-basic/account
I am lost, please your explaination and help is apprected.
Thanks
Mark says:
Added on June 13th, 2011 at 3:01 pmExcellent information! I found the site very easy to use, and the information just enough to send me out to do further research. Please keep up the good work.
Paul says:
Added on July 18th, 2011 at 5:30 amGood blog Keith. I'm new to Spring MVC annotations and have been struggling for days trying to get my own annotation-driven app working. I checked-out the mvc-basic app to, hopefully, see how it's done. I've imported the project into my NetBeans IDE. It built perfectly on the first try. Good sign! When I ran the app on Glassfish I had one slight problem (the same problem that's been vexing my with my own app).
When I click on the @Controller Example link in the welcome page, I get a resource not found error from Glassfish. The url in the address bar at this time is http://localhost:8080/account.
If I manually replace the url with http://localhost:8080/mvc-basic-1.0.0-SNAPSHOT/account, where mvc-basic-1.0.0-SNAPSHOT is the new name that NetBeans as graciously given the mvc-basic app, then the AccountController is successfully called and the Create Account view is displayed.
After that everything works fine, it's just getting past welcome page that seems to be a problem (as I said before..same problem I'm having with my own app).
Any suggestions?
buy triactol says:
Added on August 2nd, 2011 at 6:16 amSpring 3.0 is great! But I always found it a bit difficult to comprehend..
Aleks
Leon Ongkeko says:
Added on August 16th, 2011 at 12:18 amGreat Tutorial! THANKS!
chan says:
Added on December 20th, 2011 at 2:37 amin spring 3.0 mvc ,wat is the use of bindingresult .because as the validation fails the form with error ll be displayed…can u pls tell me the flow of this code from scrach
Declan Butler says:
Added on February 28th, 2012 at 9:13 amThought I'd share this for anyone trying to get the basic mvc example running
http://declanbutler.com/blog/index.php/spring-mvc-3-quick-start/
Matt Langston says:
Added on April 5th, 2012 at 8:39 pmI seem to be having trouble getting the mvc-basic sample project working. I have downloaded the SpringSource Tool Suite and imported from mvc-basic/trunk using Subclipse. The project is full of errors though. Can anyone shed some light on this?
Dmytro Chyzhykov says:
Added on April 6th, 2012 at 4:20 amA great post, Keith!
Could you add a few rows about i18n, please.
Thanks in advance.
Matthew says:
Added on May 27th, 2012 at 7:55 amHi,
I have been trying to get the mvc-basic project running but have been getting strange errors. At first i got the following error:
WARNING: Failed to classload type while reading annotation metadata. This is a non-fatal error, but certain annotation metadata may be unavailable. java.lang.ClassNotFoundException: Controller
However, after not working on it for an hour or so, when i came back to it and simply re-started the server that error no longer appeared. Is eclipse/tomcat doing any crazy caching somehow?
Now, when i run the project i can get to the welcome page but navigating to http://localhost:8080/mvc-basic/account gives me:
WARNING: No mapping found for HTTP request with URI [/mvc-basic/account] in DispatcherServlet with name 'Spring MVC Dispatcher Servlet'
This seems like the same error that Sunil (http://blog.springsource.org/2009/12/21/mvc-simplifications-in-spring-3-0/#comment-172813) and Jieyan (http://blog.springsource.org/2009/12/21/mvc-simplifications-in-spring-3-0/#comment-173684).
FYI, i am using spring framework 3.1.1. I have also posted about this on stackoverflow (http://stackoverflow.com/questions/10773611/spring-mvc-3-mvc-basic-sample-project-generates-controller-error#comment14008757_10773611)
Thanks
surendra says:
Added on November 9th, 2012 at 3:05 pmHi,I have facing problem with @NumberFormat in spring 3, is not working.. i am not understanding the problem.. plz help me ..
Thanks in Advance
David Wilson says:
Added on November 14th, 2012 at 10:24 pmIt was excellent and very informative. As a first time visitor to your blog I am very impressed. I found a lot of informative stuff in your article. Thanks for posting.
chris says:
Added on February 26th, 2013 at 4:19 pmHi,
a stupid question
my understanding of is to load up the all files with the "controller" annotation. If this is the case do we still need
if we have no components.
Thanks