Spring MVC 3 Showcase |
|

Since the big Spring 3 release last year, I've been working on a number of application development projects and extracting "showcases" of various framework features. These "showcases" are not reference applications or tutorials, they're more like acceptance tests for specific framework capabilities. After seeing a showcase, you should have a good idea of what the technology can do.
The first showcase I've put together is for Spring MVC 3, our web framework. It includes a sample project, along with a supporting slide presentation and screencast. After digging in, you should have a good understanding of what Spring MVC can do and get a feel for how easy it is to use.
mvc-showcase
In this showcase you'll see the following in action:
- The simplest possible @Controller
- Mapping Requests
- Obtaining Request Data
- Generating Responses
- Message Converters
- Rendering Views
- Type Conversion
- Validation
- Forms
- File Upload
- Exception Handling
I use jQuery to drive feature illustration by applying progressive Ajax techniques. I highly recommend using Firebug or equivalent to gain insight into the client/server interactions. I find it very educational to inspect the request and response details from the client-side, then jump to the code that executed on the server-side.
Get the code by cloning the spring-mvc-showcase project over at Github. Simply import the project into STS as a Maven Project, then drag-n-drop the project onto the "SpringSource tc Server Developer Edition" Server to run.
View the supporting slide show:
See the showcase live in this 8 minute screencast:
The mvc-showcase screencast contains music by the band The Smashing Pumpkins. The mvc-showcase screencast is not affiliated with or endorsed by The Smashing Pumpkins. All audio in the screencast is licensed for non-profit use per the terms and conditions of the live music archive at archive.org.
Summary
I hope you find spring-mvc-showcase useful and discover some "hidden gems" you might not have known about before. Please let me know also if you'd like to contribute your own additions. spring-mvc-showcase covers a lot of ground today, but there's always opportunity to cover more!
Similar Posts
- Spring Android and Maven (Part 2)
- Introducing Spring Social's Service Provider Framework
- Spring MVC 3.2 Preview: Chat Sample
- Updated Maven Support for Android Projects
- dm Admin Console Demo Screencast







David MARTIN says:
Added on July 22nd, 2010 at 2:06 pmHi,
I'm gonna download this source code. It's always nice to have a showcase to illustrate how to implement typical things. Thank you for providing us this. I'm sure it will be helpful.
David
Ben says:
Added on July 22nd, 2010 at 8:04 pmNice sample project!
However, what's with the 'resources' element labeled with "Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory" found in servlet-context.xml?
Keith Donald (blog author) says:
Added on July 22nd, 2010 at 10:10 pmBen,
Good observation. The <mvc:resources/> tag is a new feature coming in Spring Framework 3.0.4. I used it in this sample so I could achieve clean URLs without having to add a dependency on urlrewrite. Specifically, all requests into the app are routed through the Spring MVC DispatcherServlet (note the "/" mapping in web.xml). This includes requests for static /resources. When a static resource is requested, the ResourcesHandler registered by the <mvc:resources/> tag serves it up.
Keith
Daniel K says:
Added on July 23rd, 2010 at 1:31 amKeith,
I suspect Ben mentioned the resources element because it gets flagged when validated. In Eclipse I get an error, "cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'resources'.", at line 15 of src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml".
Is there a public XSD we can point to that includes this as yet unreleased version of Spring? Or can we just comment it out since it is empty anyway?
Dan
Daniel K says:
Added on July 23rd, 2010 at 2:03 amI should add that once deployed when I hit http://localhost:8080/mvc-showcase/ the page renders without all the JQuery goodness, and logs the following in Tomcat:
WARN : org.springframework.web.servlet.PageNotFound – No mapping found for HTTP request with URI [/mvc-showcase/resources/jqueryui/1.8/jquery.ui.widget.js] in DispatcherServlet with name 'appServlet'
Surely related.
Dan
Jeffery Caldwell says:
Added on July 23rd, 2010 at 4:58 amThe following approach worked for me to view the mvc-showcase. Note I am using sts-2.3.3.M2 but I don't think tat should matter.
1) svn checkout from command line outside of sts.
2) import existing project – see validation error noted above…
3) right-click no the project and do a run-as "Maven Package" (or mvn package from cmd line)
4) go to the project properties dialogue on the pane for "Deployment Assembly".
5) remove all the rows that are there.
6) add a new entry with the Folder Mapping refernce type. Choose the targets war folder, i.e. – /target/mvc-showcase-1.0.0.BUILD-SNAPSHOT.
7) finally I just right-clicked on the project and selected run-as "Run on Server" and it started up with all he goodness on tc dev instance.
Maven handled pulling down the spring 3.0.4.BUILD-SNAPSHOT stuff, and I've got to say this does look nifty. Interesting that urlrewrite dependency is going away, I should have seen that one coming.
Great work BTW you spring guys are great.
Keith Donald (blog author) says:
Added on July 23rd, 2010 at 8:39 amGuys,
Deploying the mvc-showcase project should be as simple as importing the project into STS and dragging it over to the "SpringSource tc Server Developer Edition" Server. This is shown step-by-step in the screencast. If using an IDE is not your thing, you can also deploy from the command line by running "mvn tomcat:run".
Yes, STS does flag the <mvc:resources/> tag with a red marker, but this will not prevent the app from deploying properly. The reason STS flags the tag is because it refers to the version of the mvc namespace in its XML Catalog when validating the XML file. This version is different than the version of spring-mvc-3.0.xsd in the org.springframework.web.servlet.config package of the spring-webmvc-3.0.4.BUILD-SNAPSHOT jar file included in your classpath, which is what actually gets used at runtime. Once the Spring Framework 3.0.4 release is out and STS has updated its catalog, the error marker will go away. But, I promise, the issue is just a tooling thing and will not effect the actual application at runtime (unless you comment the tag out, Dan
)
Hope this helps. Great to see you guys digging into this!
Keith
Daniel K says:
Added on July 23rd, 2010 at 11:05 amKeith – Got things working. I just missed a step. Works nicely. Thanks.
Stephane says:
Added on July 23rd, 2010 at 3:13 pmQuick question, what tool did you use to record the showcase?
Reza says:
Added on July 23rd, 2010 at 4:00 pmThis is awesome. I wish you guys have similar showcase for your other projects like SFW and Spring Security!
Great Job.
Keith Donald (blog author) says:
Added on July 23rd, 2010 at 4:38 pmStephane,
I use ScreenFlow for the Mac. It's a cinch to use and I expect I will be doing more screencasts in the future with this tool.
Reza,
Thanks for the kind words. I'm sure we'll see showcases for other projects in the future. I'd love to see one for Spring Web Flow and Spring Security, too. I encourage you to contact the Spring team whenever you have some code you think will make a good showcase addition.
Keith
Reza says:
Added on July 23rd, 2010 at 4:42 pmOne more question,
What is the status of Spring MVC's form tags with HTML5?
For example, I would like to use 'placeholder' attribute in my text inputs.
Keith Donald (blog author) says:
Added on July 23rd, 2010 at 4:51 pmReza,
Yes, you can use HTML 5 and custom attributes with the form tags in Spring MVC 3.
Keith
Mary says:
Added on July 23rd, 2010 at 7:36 pmGreat to have this showcase app for reference!
Hacking a little at the app, I've come to suspect that Spring MVC 3 is not currently supporting remoting java exception object such that the jquery's ajax() error handler would receive a valid exception object from the server. Is that correct?
If so, I will just use the @ExceptionHandler pattern you provided in the app to package exception info in the response back to the browser.
Sascha T. says:
Added on July 24th, 2010 at 6:12 pmThis showcase is really recommended.
It features many facettes of Spring MVC which have been very difficult to find seperately. All the important pieces very well sorted and seperated in directories.
Thank you Keith and keep on the good work!
Amit Panwar says:
Added on July 24th, 2010 at 10:25 pmHi,
I have a requirement to get the error messages from the database against the form fields server side validation, rather then from the properties files.
Can anyone suggest some approach?
Thanks
Amit
YangL says:
Added on July 25th, 2010 at 7:40 amgood job
jjjjj says:
Added on July 25th, 2010 at 8:32 amquite late for for spring 3 showcase but very very nice! thank you
Raju PV says:
Added on July 25th, 2010 at 1:03 pmThanks Keith. It is really awesome. Pretty clear showcase. I believe you continue the same kind of showcases for your future projects also.Good luck
sunny says:
Added on July 26th, 2010 at 2:37 amBravo.thank you for your sharing!!!
redsonic says:
Added on July 27th, 2010 at 11:38 amThanks a lot, clean work.. awesome. Spring rocks!
Corey Reil says:
Added on July 27th, 2010 at 11:05 pmKeith
With the ability to perform simple request/reply with xml as the input and output (e.g. via the MarshallingHttpMessageConverter), would there be a reason to choose the Spring MVC way vs. exposing the same type of interface via Spring Integration?
Ryan says:
Added on July 28th, 2010 at 12:11 pmI'm getting a 404 for anything under the resources path. I did not comment out the resources tag. I tried both on command line using maven and in STS. For command line, here's the script to repeat:
svn co https://src.springframework.org/svn/spring-samples/mvc-showcase
mvn tomcat:run
wget http://localhost:8080/mvc-showcase/resources/form.css
–2010-07-28 13:08:23– http://localhost:8080/mvc-showcase/resources/form.css
Resolving localhost (localhost)… ::1, fe80::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:8080… connected.
HTTP request sent, awaiting response… 404 Not Found
2010-07-28 13:08:23 ERROR 404: Not Found.
I get this in the logs, which makes it seem it did complete successfully.
DEBUG: org.springframework.web.servlet.DispatcherServlet – DispatcherServlet with name 'appServlet' determining Last-Modified value for [/mvc-showcase/resources/form.css]
DEBUG: org.springframework.web.servlet.handler.SimpleUrlHandlerMapping – Matching patterns for request [/resources/form.css] are [/resources/**]
DEBUG: org.springframework.web.servlet.handler.SimpleUrlHandlerMapping – URI Template variables for request [/resources/form.css] are {}
DEBUG: org.springframework.web.servlet.handler.SimpleUrlHandlerMapping – Mapping [/resources/form.css] to handler 'org.springframework.web.servlet.resources.ResourceHttpRequestHandler@1ef673cc'
DEBUG: org.springframework.web.servlet.DispatcherServlet – Last-Modified value for [/mvc-showcase/resources/form.css] is: -1
DEBUG: org.springframework.web.servlet.DispatcherServlet – DispatcherServlet with name 'appServlet' processing GET request for [/mvc-showcase/resources/form.css]
DEBUG: org.springframework.web.servlet.DispatcherServlet – Null ModelAndView returned to DispatcherServlet with name 'appServlet': assuming HandlerAdapter completed request handling
DEBUG: org.springframework.web.servlet.DispatcherServlet – Successfully completed request
If I just go to http://localhost:8080/, I do get the main screen but without any of the styles or javascript.
Am I missing something?
thanks,
Ryan
Jeremy Grelle (blog author) says:
Added on July 28th, 2010 at 12:29 pmRyan,
The resource handling infrastructure is still a work-in-progress (see http://jira.springframework.org/browse/SPR-7116). It's getting close to being finished, but the recent changes did break the sample. I've updated the sample to reflect the latest changes. Do an svn update and you'll be good to go.
Thanks,
Jeremy
Ryan says:
Added on July 28th, 2010 at 1:19 pm@Jeremy – An svn update fixed the issue. Thanks!
Jiyun Kang says:
Added on July 29th, 2010 at 1:55 pmAwsome Job! Thanks a lot, Spring Team
devdanke says:
Added on August 5th, 2010 at 12:27 ammust i install quicktime to watch this screencast?
why not put it in a more common video format, such as avi or flash?
given apple's anti-developer behavior of late, i won't put any of their software on my computer.
Jiyun Kang says:
Added on August 5th, 2010 at 5:10 pmDoes anyone know what makes this project runnable with just simple drag& drop down to tc server panel in STS?
Ben says:
Added on August 5th, 2010 at 6:25 pmre: JK
Not sure I understand the question. The "drap & drop" is just a short alternative to "right-click project > run on > server" where tc server is registered with STS as a server runtime. Perhaps adding the "Dynamic Web Project" facet to your project is what you're looking for.
Jiyun Kang says:
Added on August 5th, 2010 at 6:53 pmre: Ben
My question was how I can deploy the project to tc server like the demo screencast is doing here.
But your answer gave me hint to solve the issue.
It was version compatibility issue of the J2EE Web module specification.
* The server does not support version 3.0 of the J2EE Web module specification.
Thank you very much
Luis Serrano says:
Added on August 12th, 2010 at 2:51 amHi Keith,
Thanks a lot for these examples, they help understand everything a little bit more. I was wondering whether to find samples of portlet developments, specially how to test them within SpringSource.
I have found a good guide here:
http://www.manning.com/sarin/Sarin_MEAP_Ch1.pdf
And also a Hello World portlet:
http://books.dzone.com/articles/hello-world-portlet-using-Spring-3-portlet-MVC
But an "official", more extended explanation from an official would be greatly useful and appreciated.
BTW I loved the screencast soundtrack.
Cheers!
redsonic says:
Added on August 12th, 2010 at 3:03 amHi,
When using Google Chrome the result page is not displayed, and Chrome is telling me:
"Resource interpreted as document but transferred with MIME type application/xml."
How can I fix the content-type to: text/html (or text/xml for exemple)?
Thanks
redsonic says:
Added on August 18th, 2010 at 3:15 amSolution to my previous question in ResponseController.java
@RequestMapping(value="/response/entity/headers", method=RequestMethod.GET)
public ResponseEntity<String> responseEntityCustomHeaders() {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.TEXT_PLAIN);
return new ResponseEntity<String>("The String ResponseBody with custom header Content-Type=text/plain",
headers, HttpStatus.OK);
}
shriva says:
Added on August 18th, 2010 at 9:38 amnot able to download the project. getting error "could not connect to server" dont know what to do? any pointer would be appreciated.
C:\>svn checkout https://src.springframework.org/svn/spring-samples/mvc-showcase
svn: OPTIONS of 'https://src.springframework.org/svn/spring-samples/mvc-showcase': could not connect to server (https://src.springframework.org)
C:\>svn co https://src.springframework.org/svn/spring-samples/mvc-showcase
svn: OPTIONS of 'https://src.springframework.org/svn/spring-samples/mvc-showcase': could not connect to server (https://src.springframework.org)
Keith says:
Added on August 18th, 2010 at 6:45 pmNice showcase.
Has anyone found a workaround for the hard coded default character encoding in StringHttpMessageConverter?
If I am reading the code correctly, any @ResponseBody returned as a string will be encoded as ISO-8859-1 — which makes it unusable in many real world applications.
Marc Lang says:
Added on August 20th, 2010 at 2:58 amHi,
The project runs fine by dragging onto the tc server (this is my first look at springsource)
However, I am still getting the error in Eclipse to do with the resources tag.
How do I go about updating to resolve this?
I have done a help > check for updates, but this didn't resolve it.
I see that 3.0.4 has been released now.
Keith says:
Added on August 21st, 2010 at 8:14 pmA great enhancement to the showcase would be a @ResponseBody annotated method returning a string containing Japanese (or other high number unicode) characters.
Gerry Kaplan says:
Added on August 25th, 2010 at 11:45 pmI am also still getting the resource error. True, it executes fine, but for those of us who work in Eclipse, this makes a lot of red mess. Any idea when we can expect the resources tag not to be flagged as an error?
Bryan says:
Added on August 27th, 2010 at 8:19 amI am having issues starting the server, I keep getting the timeout after 120 seconds. I tried dragging and dropping the mvc-basic project and it started immediately. Is there something I'm doing wrong? The error I get is below.
INFO: Starting service Catalina
Aug 27, 2010 9:14:27 AM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: SpringSource tc Server/6.0.20.C
Aug 27, 2010 9:14:27 AM org.apache.tomcat.util.modeler.Registry registerComponent
SEVERE: Null component Catalina:type=JspMonitor,name=jsp,WebModule=//localhost/mvc-showcase,J2EEApplication=none,J2EEServer=none
java.lang.reflect.InvocationTargetException
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:592)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:290)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:415)
Caused by: java.lang.UnsupportedClassVersionError: Bad version number in .class file (unable to load class org.springframework.samples.mvc.flash.FlashMapFilter)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1894)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:887)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1351)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1230)
at org.apache.catalina.startup.WebAnnotationSet.loadClassAnnotation(WebAnnotationSet.java:145)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationFilterAnnotations(WebAnnotationSet.java:84)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:57)
at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:297)
at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:1068)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:261)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4339)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:741)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:587)
… 6 more
javamug says:
Added on August 28th, 2010 at 9:51 amI am getting the same error as Bryan:
SEVERE: Null component Catalina:type=JspMonitor,name=jsp,WebModule=//localhost/mvc-showcase,J2EEApplication=none,J2EEServer=none
java.lang.reflect.InvocationTargetException
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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:290)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:415)
Caused by: java.lang.UnsupportedClassVersionError: Bad version number in .class file (unable to load class org.springframework.samples.mvc.flash.FlashMapFilter)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1894)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:887)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1351)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1230)
at org.apache.catalina.startup.WebAnnotationSet.loadClassAnnotation(WebAnnotationSet.java:145)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationFilterAnnotations(WebAnnotationSet.java:84)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:57)
at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:297)
at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:1068)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:261)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4339)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:741)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:587)
… 6 more
Am I doing something wrong please let me know
Roman says:
Added on September 8th, 2010 at 4:39 pmI am getting 404 error on http://localhost:8080/mvc-showcase/.
No exceptions in the logs….. and server started successfully
Rett says:
Added on September 11th, 2010 at 5:13 pmKeith — thanks for providing this example and video tutorial. To follow along exactly, I downloaded STS, got the latest mvc-showcase via svn, and imported the project; however, the SpringSource tc Server gave me an error on starting (that I haven't been able to solve). Error is below. Can you please assist?
Thanks, Rett
INFO: Starting Servlet Engine: SpringSource tc Server/6.0.20.C
Sep 11, 2010 2:52:09 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1384)
Rett says:
Added on September 11th, 2010 at 7:20 pmOk … well! Turns out totally exiting STS and going back in and then restarting the server fixed this issue. Starting and stopping the server multiple times within STS did not resolve it. Not sure what's going on — why that solved the ClassNotFoundError.
JamesZ says:
Added on September 27th, 2010 at 3:12 pmSame error here running on Tomcat 6.0 JDK 1.6:
Sep 27, 2010 2:59:52 PM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter flashMapFilter
java.lang.ClassNotFoundException: org.springframework.samples.mvc.flash.FlashMapFilter
JamesZ says:
Added on September 28th, 2010 at 8:53 amIt's my maven dependencies not set to be deployed to web-info/lib. It works very well now. Thanks.
reza says:
Added on November 6th, 2010 at 7:30 pmHTML5 question again,
will generate
and The http://validator.w3.org is giving error as "Duplicate attribute type."
Marc says:
Added on November 19th, 2010 at 5:27 amJust to keep it interesting login_security_check was changed to j_spring_security_check. For those who are surprised that login is suddenly not working anymore after replacing the library with this version
paul says:
Added on November 23rd, 2010 at 12:18 amgreat post. i wanna share also a spoon-feed tutorial on Spring MVC
http://www.adobocode.com/spring/a-spring-web-mvc-tutorial
hope it will help people!
sunxiaozhou says:
Added on December 20th, 2010 at 3:50 amthank you ,Keith Donald ,i've downloaded and run it successfully ,now i will see how you work it, thanks again.
dukai says:
Added on January 24th, 2011 at 11:26 pmHey Keith
I'm come from china,This is my first time to try sprnigMVC,even spring2.5 has MVC,but I never have a test,so at this time,there comes some troubles,please help me,thanks.
My troubles are like this:
1."MaskFormat": my convert does not work,this is the response:Converted '123456789' with a custom converter ,I think it should be 123-45-678?but! for what? how does @MaskFormat("###-##-####") works? I have confirm beans in servlet , i promise it works right.
2."Json": after i click button 'Read Json' that comes a http-status directly.HTTP Status 415 – Firstly, I was work in IE6, Then change to FireFox, badly it does not work either. This situtation appear in 'Write Json', but at that time it response 'barapple' in red color, i think it must be errorResult.
please help me , i'm looking forword you email, contract me dukai1008#hotmail.com,#->@
thanks
best wishes
dukai
Simon Welland says:
Added on February 15th, 2011 at 8:28 amKeith thanks for such a clean and powerful api.
I found that following your svn co in the video and importing into sts 2.5.2 gave build errors that didn't appear on the video.
Adding in jaxb dependency to the pom.xml seemed to fix it.
Cheers,
Simon.
SSakSSri says:
Added on February 15th, 2011 at 11:08 pmThank you for your great example.
This sample project works fine in STS.
But it's not working in Tomcat v6.0 Server.
I got this error message
================== error stack =====================
ERROR: org.springframework.web.servlet.tags.form.LabelTag – Invalid property 'name' of bean class [org.springframework.samples.mvc.form.FormBean]: Bean property 'name' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
org.springframework.beans.NotReadablePropertyException: Invalid property 'name' of bean class [org.springframework.samples.mvc.form.FormBean]: Bean property 'name' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:707)
at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:699)
Is there any dependancy requirement for this project?
dukai says:
Added on February 16th, 2011 at 5:45 amDear SSakSSri:
I am come from china , nice to meet you.
you problem is 'spring roo', in this case, it bulid by that
aslo in STS, it works well, but in other case, you should run in 'roo' case mode, see?
that means you should run it with commond!
to solve this problem, you should add getter/setter method by you hand!!
yes, you hand! not auto.ok?
good luck!
Keith Donald (blog author) says:
Added on February 16th, 2011 at 8:53 amHi SakSSri:
Are you building the .war to deploy to Tomcat 6 using Maven? The pom.xml of showcase invokes AspectJ to weave in ITDs managed by Roo. If this is not done, the getter/setters managed by Roo for some of the types will not be weaved in, and you'll get the error you see above. Curious if you're doing something different to build the app, or if you're just invoking mvn and deploying the .war it builds (which is what I would expect).
Keith
Alex says:
Added on March 9th, 2011 at 5:14 pmJavaBean Property Binding is not working for me.
This is what i'm getting:
JavaBean Property Binding
* PrimitiveConverted JavaBean
* DateConverted JavaBean
* MaskedConverted JavaBean
* List ElementsConverted JavaBean
* @Formatted List ElementsConverted JavaBean
* Map ElementsConverted JavaBean
* NestedConverted JavaBean
Alex says:
Added on March 9th, 2011 at 5:18 pmI also get run-time exceptions on validation:
http://localhost:8080/mvc-showcase/validate?number=3&date=2029-07-04
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.web.bind.annotation.support.HandlerMethodInvocationException: Failed to invoke handler method [public java.lang.String org.springframework.samples.mvc.validation.ValidationController.validate(org.springframework.samples.mvc.validation.JavaBean,org.springframework.validation.BindingResult)]; nested exception is java.lang.IllegalStateException: JSR-303 validated property 'number' does not have a corresponding accessor for Spring data binding – check your DataBinder's configuration (bean property versus direct field access)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:656)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.springframework.samples.mvc.flash.FlashMapFilter.doFilterInternal(FlashMapFilter.java:33)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
root cause
febmaroct says:
Added on March 13th, 2011 at 8:34 amKeith, Getting Spring showcase working in STS was easy. Good work. I am using Hibernate for ORM. I have spent lot of time to add Hibernate in the mix and after reading all the blogs out there now I am thoroughly confused.
Is there a decent article that show how to put together a Spring MVC 3 Hibernate using STS framework?
Any help from anyone will be greatly appreciated!
Thanks
lora says:
Added on March 27th, 2011 at 12:11 pmHi Keith,
I am getting this error
org.apache.jasper.JasperException: Unable to read TLD "META-INF/c.tld" from JAR file "file:/Users/lora/general/projets/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/mvc-showcase/WEB-INF/lib/jstl-1.2.jar": org.apache.jasper.JasperException: Failed to load or instantiate TagLibraryValidator class: org.apache.taglibs.standard.tlv.JstlCoreTLV
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:181)
org.apache.jasper.compiler.TagLibraryInfoImpl.(TagLibraryInfoImpl.java:182)
org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:386)
org.apache.jasper.compiler.Parser.parseDirective(Parser.java:449)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1396)
org.apache.jasper.compiler.Parser.parse(Parser.java:130)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:255)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:103)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:185)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:347)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.springframework.samples.mvc.flash.FlashMapFilter.doFilterInternal(FlashMapFilter.java:33)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
Maxime says:
Added on March 30th, 2011 at 10:27 am@lora check that you don't have servlet-api or jsp-api in your lib directory (if you're using eclipse, unckeck them in "Project Properties > Deployement Assembly")
http://www.google.com/search?q=Unable to read TLD "META-INF/c.tld" from JAR file
Maxime
Kamal says:
Added on April 17th, 2011 at 11:24 amPlease Keith,
you are a great person, I saw lot of your articles and tutorials,I am sure you are very busy, but please bear with us the new people to this field, please can just explain or someone here reading this article how to :
Get the code by checking out the mvc-showcase project from our spring-samples repository. Simply import the project into STS and drag-n-drop the project onto the "SpringSource tc Server Developer Edition" Server to run.
I don't understand how to get this project ?
what is STS ?
Thanks Lot.
Shiva says:
Added on April 17th, 2011 at 1:46 pmHi,
I have Maven and tortoise svn installed in my PC.
I opend Tortoise and checkec out mvc-showcase from :
https://src.springframework.org/svn/spring-samples
C:\SpringSRC\mvc-showcase\
.settings
src
target
.classpath
.project
.springBeans
pom.xml
I went to Eclipse
File –> Import –> General –> Existing Projects into workspace
I did not see any jsp files,
When I tried to run the project, I got :
HTTP Status 404 –
——————————————————————————–
type Status report
message
description The requested resource () is not available.
——————————————————————————–
Apache Tomcat/6.0.28
Can you please help me.
Thanks,
Majid
MSS says:
Added on April 24th, 2011 at 2:21 pmI tried and in the first shot it's working. I am so glad. I installed the springsource-tool-suite-2.6.0.SR1-e3.6.2-win32-installer. Downloaded the mvc-showcase and "Run As" Run on Server. It worked like charm
Yet to explore the code. Looking forward for learning more
regards,
MSS
wheleph says:
Added on April 25th, 2011 at 12:00 pmGreat showcase, thank you!
I did spot a minor mistake in the code though. In /mvc-showcase/src/main/java/org/springframework/samples/mvc/mapping/MappingController.java method byHeaderNegation is mapped incorrectly and when a user clicks a link "By not presence of header" he gets "Mapped by regexp!" instead of "Mapped by path method not presence header!"
Laura says:
Added on April 25th, 2011 at 12:53 pmHi everybody,
Where to get a war file of this application, I have difficulty to download this project and import it to eclipse.
It will be nice if someone show me how to .
Thanks
Laura
Manjit says:
Added on May 5th, 2011 at 11:57 pmHi Keith,
Thanx for this presentation and showcase.I have always been a fan of yours…and watch all of your talk shows in infoQ.
By following your screencast i checked out the mvc-showcase project from our spring-samples repository. Imported the project into STS and drag-n-droped the project onto the "SpringSource tc Server Developer Edition" Server to run.
When i start the server, i get this Exception —
"SEVERE: Exception starting filter flashMapFilter
java.lang.ClassNotFoundException: org.springframework.samples.mvc.flash.FlashMapFilter
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:269)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)
at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:115)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4001)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4651)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:568)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:637)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:563)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:498)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1282)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:807)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
at org.apache.catalina.core.StandardService.start(StandardService.java:519)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
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:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
May 6, 2011 9:50:49 AM org.apache.catalina.core.StandardContext start
SEVERE: Error filterStart
May 6, 2011 9:50:49 AM org.apache.catalina.core.StandardContext start
SEVERE: Context [/mvc-showcase] startup failed due to previous errors
May 6, 2011 9:50:49 AM org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext"
My MVC showcase code is not giving any kind of Dependency error or something like that
What might be the reason?
Please help me out?
numan says:
Added on May 21st, 2011 at 12:43 amI created a simple mvc project to play around based on the showcase. But I can't get the Roo annotations to work when I run the code through STS (run -> run on server).
Shouldn't that, behing the scenes, invoke the aspectj compiler to weave the tostring and accessors/modifiers.
What am i doing wrong?
Andy says:
Added on June 6th, 2011 at 10:25 amWhat's with the project download. You download the zip and unpack it. Then you try to import it as an existing project and tool suite can't find it! I have to import it as a maven project. Very frustrating.
Keith Donald (blog author) says:
Added on June 6th, 2011 at 11:18 amThere is no .zip file, so I'm not sure what you're talking about. The project is available at https://github.com/SpringSource/spring-mvc-showcase. Clone it there, then import as a Maven Project into Eclipse or the SpringSource Tool Suite. From there, drag the project to your server to run. It's pretty easy.
Raj Kotecha says:
Added on June 9th, 2011 at 3:02 pmFor those who are getting the "SEVERE: Exception starting filter flashMapFilter problem.
The solution is getting your Application Server (Tomcat or whatever you happen to use) to know where Maven is storing the various Jar file dependencies. At least that's what I think (my background is Microsoft .NET and have been trying to learn Spring JAVA Hibernate MVC etc for a week or so.)
This web page has instructions on HOW you configure the App Server within STS / Eclipse so it knows where your Maven dependencies are:
http://www.mkyong.com/spring/spring-error-classnotfoundexception-org-springframework-web-context-contextloaderlistener/
NOTE: On Mac OSX the jar files will be in /Users/YourUsername/.m2/Repository
Keith Donald (blog author) says:
Added on June 9th, 2011 at 3:16 pmIt would be much better to use Ant, Maven, or Gradle to build your .war and have that war include the necessary .jar file dependencies in WEB-INF/lib. mvc-showcase uses Maven and if you deploy the war Maven builds to Tomcat it contains the required libs. It is not a good idea to point Tomcat at your maven repository.
Raj Kotecha says:
Added on June 9th, 2011 at 4:04 pmCouple of things:
Video to add it to STS. I ran into a small problem when I tried the Open existing project approach (it didn't find a project under MVC-Showcase. So I tried Open Maven project (figuring the POM.xml file would get picked up) and that worked.
1. I got the project from Github. And followed the mvc-showcase (smashing pumpkins
Once this was done I noticed that there wasn't a lib dir. under WEB-INF. I ended up creating one but wasn't sure if that was the right thing to do. Is it?
2. How do I "deploy the war file to Tomcat"? I mistakenly thought that if I dragged my project to Tomcat after building it then that would do the trick. What am I missing?
Does this page contain the answer: http://tomcat.apache.org/tomcat-7.0-doc/deployer-howto.html
Malika says:
Added on June 9th, 2011 at 4:42 pmI am addressing this to Keith Donald.
We respect you, we love what are you doing so people learn, you always did great job.
BUt how about the newbie people, they don't have a chance to learn ?
You said :
There is no .zip file, so I'm not sure what you're talking about. The project is available at https://github.com/SpringSource/spring-mvc-showcase. Clone it there, then import as a Maven Project into Eclipse or the SpringSource Tool Suite. From there, drag the project to your server to run. It's pretty easy.
Why not give us (we, the newbies) some time and show us with couple of lines how to do it step by step.
Thanks
Malika
Keith Donald (blog author) says:
Added on June 9th, 2011 at 5:17 pmRaj,
1. Yes, Import as Maven project is correct.
1a. No, creating your own /WEB-INF/lib is not the right thing to do. When you deploy the project, which is also a "Dynamic Web Project", inside Eclipse, Maven (m2Eclipse) and Eclipse WTP (Web Tools Platform) will work together to ensure the jars are copied to /WEB-INF/lib for the container you are deploying to.
2. To deploy the project to a Tomcat Server inside Eclipse, simply drag it over to your Tomcat Server as you say and start her up. If it's not finding the libs, something is going wrong between m2Eclipse and WTP. I would try doing a project clean. Perhaps deleting the project and re-importing. Some of my colleagues call this the "Eclipse dance". What you definitely don't want to do is manually copy the libs yourself–then these tools aren't doing their job.
A couple of other things to check:
- Make sure you are deploying to Tomcat 6 or >.
- Perhaps try out the latest SpringSoure Tool Suite? It has the latest m2eclipse and WTP pre-integrated for you. This is what I'm running.
You can also deploy from the command line by simply running "mvn clean install tomcat:run", as long as "mvn" (Maven) is in your system path.
Hope this helps.
Keith
Keith Donald (blog author) says:
Added on June 9th, 2011 at 5:24 pmHi Malika,
I will create a wiki page @ the mvc-showcase project on Github shortly that has step-by-step instructions to getting and running the project. This should compliment the README by providing more detail for those new to Git, Github, Maven, Eclipse, Tomcat, and Spring. I hope it helps.
Keith
Raj Kotecha says:
Added on June 9th, 2011 at 7:37 pmIt seems to be working now and on all 3 of my configured servers
I removed all the direct JAR references I'd setup on Tomcat; I take your point about manually managing these references as being a bad thing.
My theory is that perhaps I didn't "Build" the project before I dragged it onto the server and hit run? So maybe there wasn't a war file?
Strangely I can't create my own MVC project easily using STS 2.6.1'S Spring Template Project -> Spring MVC Project. The resulting project crashes when I try to run it on Tomcat 7. I guess I'll try going the "Dynamic Web Project" route and see if that works better. I just have to figure out, step by step, how to create a blank Spring MVC Project with Maven support.
Overall I'm really impressed with all the support tools available for Java development (Spring, Hibernate, MVC, Gradle, Maven, etc etc.) Just wish I could learn them faster
Andy Smith says:
Added on June 16th, 2011 at 6:30 amKeith, the only immediately obvious download I can see on github is a zip or gz. That'll be the button with download written on it! Maybe I've missed a lot in my career, but what is the process for "cloning" from this site? Words like that kind of confuse me.
Raj Kotecha says:
Added on June 16th, 2011 at 7:10 amHi Andy,
I had similar questions
I found the steps on Git's main website were quite useful in setting up and getting the source code:
Windows: http://help.github.com/win-set-up-git/
Mac: http://help.github.com/mac-set-up-git/
Linux: http://help.github.com/linux-set-up-git/
Once you've setup yourself up, look at the "Fork a Repository" URL at the bottom of the setup page for details on how to get the code from a repository (like mvc-showcase).
Best
Raj
Keith Donald (blog author) says:
Added on June 16th, 2011 at 8:18 amAndy, Raj, Malika, all:
I didn't even notice the "Downloads" feature of github, thanks for pointing this out. Give that, yes, you can download the repository as a zip if you want, if you do not have a git client already installed on your machine. That should work fine, although keep in mind if you go that route the download is a static snapshot of the code and it won't be possible to "pull" down incremental updates (git "pull" is basically the equivalent of cvs/svn "update").
"Cloning" a git repository is similar to a cvs/svn "checkout". The term "clone" is used because this process involves creating a local copy of the repository on your machine that you can commit to independently of the "remote" repository. Git is a distributed version control system (DVCS), instead of a centralized system like Subversion, and that's why some of the terminology is different than what you may be used to. You might find my article on "Social Coding in Spring Projects" helpful http://blog.springsource.com/2010/12/21/social-coding-in-spring-projects, along with this introduction to DVCS: http://betterexplained.com/articles/intro-to-distributed-version-control-illustrated. Github also has good tutorials for using their platform at http://help.github.com that range from beginner level to advanced.
As Raj suggests, in order to "clone" the mvc-showcase repository on github, you first need a git client installed on your machine. Once you have that, you can execute "git clone git://github.com/SpringSource/spring-mvc-showcase.git" from the command line to bring down the code (if you're running behind a corporate proxy you may need to use the http URL). From there, if you have Maven installed, you can run "mvn tomcat:run" to build and deploy the app to an embedded Tomcat instance. You can also "Import as Maven Project" into your preferred IDE, such as Eclipse (perhaps the SpringSource Tool Suite distribution), or IDEA.
There is no reason to "Fork" the spring-mvc-showcase repository unless you expect to make your own changes to the code and you wish to share those changes with others. "Forking" is the process of creating a clone of a repository on Github's servers associated with your Github profile. It's especially useful when you would like to make and share changes to a code base, but you don't have write access to the "main" repository. The github help discusses "forking" in detail, as well as the process of submitting "pull requests" to the main project team to have your changes integrated.
Hope this helps. I apologize if I assumed too much as it relates to folk's experience with some of these newer, ancillary technologies such as distribution version control and specifically Git. I will say I do believe the DVCS model to be the future of software development version control, and I believe Git has the most momentum as a DVCS implementation and Github has the most momentum as a Git-based Social coding platform. I do believe becoming well-versed in the use of DVCS will be an asset to you in the future.
All the best,
Keith
charter private jet rates says:
Added on June 27th, 2011 at 6:45 amthanks for recommending firebug, a really great plugin
Mark says:
Added on July 7th, 2011 at 1:24 pmHey Keith. Great demo. Question about custom jars or third party libs not [yet] managed by Maven. Where do you normally put them in your web projects since you say not to create a "/WEB-INF/lib" so they then get included in the build? Of course some jars i don't want copied (like jdbc drivers).
rajaneesh says:
Added on July 11th, 2011 at 6:01 amHi,
I'm new to jQuery,Spring and facing the below problem.
My controller is returning a jsp file to the Ajax call made. Now in my jquery i need to read the jsp file to show a popup if one property of the form object is set.
How can i do it.
Thanks in advance.
Michel says:
Added on July 11th, 2011 at 8:43 amGreat, I am looking forward to exploring it. It would have been nice to get the showcase without having to fight with git for an afternoon
Ed Randall says:
Added on August 31st, 2011 at 8:02 amThe following commands checked out a copy of the projects for me; I am using "cygwin" and stuck behind a corporate Microsoft NTLM firewall:
$ export http_proxy="http://username:password@proxyhost:port"
$ git clone http://github.com/SpringSource/spring-mvc-showcase.git
TM says:
Added on September 13th, 2011 at 5:59 pmI have put together some screenshots to help those folks who are facing issues importing this project into eclipse as maven project and deploying to Tomcat.
check this out:
http://eneuron.blogspot.com/2011/09/spring-mvc-3-showcase-git-maven-eclipse.html
Comments welcome!!!
Keith Donald (blog author) says:
Added on September 13th, 2011 at 7:03 pmTM,
That's a lot more steps than I would expect. There should be no reason to convert the project to a web project. When you "Import as Maven project", m2eclipse should recognize the project as war project and convert it to a Eclipse Dynamic Web Project for you. It should also deploy without issue. If using the SpringSource Tool Suite, this is easy since m2eclipse is included in that distribution.
Keith
Mark says:
Added on September 13th, 2011 at 9:06 pmI am pretty sure i just imported it as a maven project into STS and ran it on Tomcat.
mori says:
Added on September 15th, 2011 at 6:25 pmthanks a really great plugin
Rohit says:
Added on October 4th, 2011 at 7:27 amNeed example of multiple file upload using spring mvc 3.0 and jQuery
Rohit says:
Added on October 4th, 2011 at 7:30 amI Need example of multiple file upload using spring mvc 3.0 and jQuery
Ravinder Singh Maan says:
Added on October 7th, 2011 at 6:19 amBest example of Spring MVC.Thanks Keith.
Amit says:
Added on October 17th, 2011 at 3:54 amHi,
I am trying to write client to post xml and consume it in the method with @RequestBody annotation. But it seems that the xml does not bind with the Object. I have done like (as given in the example):
@RequestMapping(value="/xml", method=RequestMethod.POST)
public @ResponseBody String readXml(@RequestBody JavaBean bean) {
return "Read from XML: " bean;
}
I am getting Http error 415. In my config I have which is supposed to register all required converters. I have put jaxb in the class path.
Please provide a client for the above. This is a snippet from the downloadable example.
Thanks
Amit
Amit says:
Added on October 17th, 2011 at 4:00 amHi,
I am trying to write client to post xml and consume it in the method with @RequestBody annotation. But it seems that the xml does not bind with the Object. I have done like (as given in the example):
@RequestMapping(value="/xml", method=RequestMethod.POST)
public @ResponseBody String readXml(@RequestBody JavaBean bean) {
return "Read from XML: " bean;
}
I am getting Http error 415. In my config I have use mvc:annotation-driven which is supposed to register all required converters. I have put jaxb in the class path.
Please provide a client for the above. This is a snippet from the downloadable example.
Thanks
Amit
Curious says:
Added on May 21st, 2012 at 3:56 pmHi everyone!
How to intercept LocaleResolver to look into PathVariable and change the locale
For example if someone hit below url, the locale should be set to en_HK on the fly.
http://mysite.com/hk/en/cool.html
I am wondering if we could do this with intercepting localeresolver?
if not please suggest the best approach of doing this.
Thanks
C.