Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • 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 ...
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Need help on Spring MVC hello world

Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, I am trying to learn Spring MVC on NetBeans using Hibernate and frankly I am stuck. Any help is appreciated. I am only trying to do a very simple "hello world" type site.
Somone would on the first page hit a submit button and the resulting page would have a list of values from the DB. Sounds pretty simple right?
I've included 5 very short files here that will hopefully help you to help me if you are so inclined.
"web.xml", "dispatcher-servlet.xml","index.jsp", "", "secondView.jsp"

The way I understand how Spring MVC should work, using my files, is as follows...
1) Running the project from NetBeans, the index.jsp file is brought up.
This happens because the Web.xml is consulted, which has the following line...
" <welcome-file>redirect.jsp</welcome-file>"
one the redirect.jsp is consulted, we see that it has the following...
"<% response.sendRedirect("index.htm"); %>"
so with that redirect we go back to the web.xml which has the following...
so with that request coming in as index.htm it is to be handled by the dispatcher servlet.
In the dispatcher servlet's config file, the view resolver will add the following...
p:suffix=".jsp" />
so index.htm gets changed to /WEN-INF/jsp/index.jsp and that page is brought up.
2) At this point the index.jsp is brought up. The only thing in this file is a form with a submit button. The intent is just to have someone press the button and info from the DB is returned on screen. I have Hibernate as part of this web project and I have created a java class "" based on a DB table "Team". It is populated with a few records.
Currently what I am seeing is that once the index.jsp comes up and I hit submit, it is giving a 404.
This is the URL shown for the form
if I do a view source it shows it as index.jsp. When I hit submit it gives a 404 with this url
btw, "HelloWebFour" is the name of my project in NetBeans.
I am not sure what is happening, if my understanding is right or if I need to add anything. any help is appreciated...
The very short code files are below...










Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could be you are missing <mvc:annotation-driven /> in your dispatcher-servlet.xml

you will also need to define the namespace for it.. in the beans tag as..



in your schemaLocation ...

Ranch Hand
Posts: 672
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are mapping *.htm requests to spring dispatcher servlet, but in requestmapping you give it as /team in controller, change this to team.htm in your controller and JSP and then check.
    Bookmark Topic Watch Topic
  • New Topic