Monday, August 9, 2010

Adding Spring Web MVC

I'll try to be brief.

Basically, you need to add a new Servlet on you web.xml, a configuration file (let's call it webApplicationContext.xml) and some Annotations.

This is my example:

My web.xml

The framework will, on initialization of a DispatcherServlet, look for a file named [servlet-name]-servlet.xml (webApplicationContext-servlet.xml) in WEB-INF by default, but if you provide parameter "contextConfigLocation" you can define a location and name for your configuration file.

My webApplicationContext.xml

Which basically is divided in 3 sections:

  • We're going to use configuration based onn annotations
  • Location of my Controllers
  • And where are located my JSP's

In my next entry I'll cover how it looks like a Controller & JSP.

No comments:

Post a Comment