Sunday, November 29, 2009

Creating a Simple Spring Web Application

The below procedure will help you to create your own web application

Pre-requiste:

You need an IDE(eg.Eclipse,RAD,NetBean etc) and java installed in your system.

Follow the below procedure to create using Eclipse IDE:

1) Create a Dynamic Web Project in your eclipse.
2) Configure your web.xml according to your need. The bellow is the given basic web.xml


xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
simple-security

simple-form
org.springframework.web.servlet.DispatcherServlet
1



simple-form
*.html



index.jsp




3) The name of the dispatcherServlet is simple-form.
4) You need to configure the list of pages that you are going to visit in the dispatcherServlet.
5) The below is the simple configuration:

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">




indexController



class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/jsp/"
p:suffix=".jsp" />


class="org.springframework.web.servlet.mvc.ParameterizableViewController"
p:viewName="index" />



6) Create a index.jsp. Hence your web application has been created.