• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Spring 3 MVC Controller Not Returning Views Properly

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have recently started learning Spring MVC (using Eclipse with Tomcat 7 server) but am not a new Java developer. I have updated a simple 'Hello World' example to suit to my needs but the views that are being displayed when I execute the program are not rendering properly. When I run the program the welcome page is displayed as expected and it includes 2 links - when I click on either of the links, the URL is correct and is as follows:. However both the artGallery.htm and fashionGallery.htm views display the same content as the welcome page instead of rendering their respective content. Seems like a simple enough fix but what am I missing?? My first guess is something in the Controller is not configured correctly but since I am new to Spring, I need some expert insight :-). Please see the code snippets below and I will provide any additional information that is needed. Thanks so much for your help!

 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since Spring 2.5 the preferred write your controllers is to use annotations. This way you are not coupled as tightly to the Spring framework. I am going to give you the same recommendation I usually do for those just starting.

First of all download STS (It is eclipse with all the Spring bells and whistles attached). This project is maintained by SpringSource and also has tc server already configured and ready to deploy to (tc server is Tomcat 7 with some extras). Using this you can create one their template projects to get a good idea of how things should be done.

Download STS here:
http://www.springsource.org/sts

Then once you have it create a Spring MVC project using the template

File -> New Spring Template Project -> Spring MVC project
 
Bill Gorder
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also please UseCodeTags when posting in the future. And welcome to Java Ranch
 
Jay Doss
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the welcome Bill! I will download STS and see if that can get me on my way any easier (although I think this is a pretty straightforward example but it is giving me a headache!). I will be sure to follow up once I find a resolution.

 
Bill Gorder
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sure the problem with the example you were looking at is it uses the 'old way'. Newer Spring versions have a much cleaner approach to handling many things which is why I encourage those learning to use the newest version of Spring. When looking at tutorials try to find ones that are using at least Spring 3. The template projects available in STS are great way to learn some of the best practices at least for basic project structure and configuration.

Whenever you see a controller extending some other class in the Spring framework move on to a different example

Good Luck!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic