Latest Tutorials| Questions and Answers|Ask Questions?|Site Map

Home Answers Viewqa Spring spring web

Have Programming Question? Ask it here!

spring web
1 Answer(s)      2 years and 10 months ago
Posted in : Spring

Hi can you explain the flow of spring web programatically.........

View Answers

October 18, 2011 at 12:42 PM

Hi at first please insert the all the relevant jar files in WEB-INF/lib directory, add the following servlet configuration in your web.xml file.


Now write the dispatcher-servlet.xml file and put it into the same directory as web.xml file.

In dispatcher servlet the main thing you have to do is to specify the path of the Controller class, as

<context:component-scan base-package="net.roseindia.controller" />

the following are the typical configurations in dispatcher-servlet.xml file

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""
    xmlns:xsi="" xmlns:p=""

    <!-- Enable annotation driven controllers, validation etc... -->
    <mvc:annotation-driven />
    <context:component-scan base-package="net.roseindia.controller" />

    <bean id="viewResolver"
        <property name="prefix">
        <property name="suffix">
    <bean id="multipartResolver"

Then write the form as

<%@ taglib prefix="form" uri=""%>
<h2>Please Enter Login Detail</h2>
<form:form action="loginForm.htm" commandName="loginForm">
    <table cellpadding="5" cellspacing="10" bgcolor="#00B8E6">
            <td><form:label path="userId">User Id</form:label></td>
            <td><form:input path="userId" /></td>
            <td><form:label path="password">Password</form:label></td>
            <td><form:password path="password" /></td>
            <td colspan="2" align="center"><input type="submit" value="Submit" /></td>


and corresponding bean class would be

package net.roseindia.model;

public class LoginForm {

    private String userId;
    private String password;

    public String getUserId() {
        return userId;

    public void setUserId(String userId) {
        this.userId = userId;

    public String getPassword() {
        return password;

    public void setPassword(String password) {
        this.password = password;

And Now you need the write the controller class. The package wold be the same as you specified in the dispatcher-servlet.xml file i.e net.roseindia.controller

The controller class is given below please consider it..

package net.roseindia.controller;

import javax.validation.Valid;

import net.roseindia.model.LoginForm;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

public class MyController {

    @RequestMapping(method = RequestMethod.GET)
    public String getRequest(ModelMap model) {
        LoginForm login = new LoginForm();
        model.put("loginForm", login);
        return "loginForm";

    // @RequestMapping("loginForm.htm")
    @RequestMapping(method = RequestMethod.POST)
    public String postReQuest(ModelMap model, @Valid LoginForm login) {
        // LoginForm login = new LoginForm();
        System.out.println("Id- " + login.getUserId());
        System.out.println("Id- " + login.getPassword());
        model.put("loginForm", login);
        return "loginForm";


Related Tutorials/Questions & Answers:
spring Web Services - Spring
spring Web Services  Hi, Can any one explains or give me some example which gives me that how to start up spring web services. Thanks, mahi
spring web - Spring
spring web  hi thanku for reply :) Actually i dint get u what is meaning of spring web as i understand i am telling you. I am using eclipse and jar files like spring.jar,tlds of spring. hibernet.jar and also required jars
Spring web service - Spring
Spring web service   Respected service, I have found an error in this manner(Connecting to tomcat then coming this error at first time only) and then working correctly. error coming only at first time. What
spring web
spring web  Hi can you explain the flow of spring web programatically... in WEB-INF/lib directory, add the following servlet configuration in your web.xml... http
Spring Web, Spring Web Modules, Spring Web Example
Spring Web In this section we will discuss about the modules of Spring Web layer. The Spring Web modules allows the developers to develop/manage web... easier. The Spring Web Layer contains following modules: Web
Web application - Spring
Web application  I need one simple complete web application example using springs with database connection,i saw ur demo but it is not succfient.can u send to am a beginner
Spring web UrlBasedViewResolver
Spring web UrlBasedViewResolver...;org.springframework.web.servlet.view.JstlView" /> <property name="prefix"> <value>/WEB...:// http
How to make web appliction using spring and hibernate - Spring
How to make web appliction using spring and hibernate  Hi Actually i want to make an web application using spring as front end and hibernate as back...  Hello,Are you using Spring web for developing the application
Spring web mvc 3.0 mysql project
Spring web mvc 3.0 mysql project  Hello Sir... I want a complete database connectivity web project in spring mvc 3.0..Just give me a simple example...:
develope a web site using JSF,Spring,Hibernate.
develope a web site using JSF,Spring,Hibernate.  I have to develope a web site,just like Facebook,which will have all the functionality as wall post...,Spring Framework,Hibernate,JMS. Please anyone provide me idea,how to proceed ahead
Getting HTTP 404 error in Spring web MVC with Hibernate Integration
Getting HTTP 404 error in Spring web MVC with Hibernate Integration   Hi, i am Getting HTTP 404 error in Spring web MVC with Hibernate Integration...;Please visit the following links:
Spring Architecture
for object-relational mapping APIs, including JDO, Hibernate and iBatis. Spring Web: is part of web application development stack. Spring DAO:- (Data Access Object... a consistent API. Spring Web MVC: provides the MVC implementations for the web
Spring Web Annotation Classes
Spring Web Annotation Annotation is introduced since java 5. It is a new kind... and it is not a part of your program. Spring framework also provides a wide range of annotation, some of them which is commonly is used in Spring MVC is explained
Hibernate and Spring
and Spring for developing web applications. Read how you can integration Hibernate and Spring in web application at Developing Struts, Hibernate and Spring based... can integrate Hibernate, MVC framework (Struts/Spring Web), Transaction managers
BeanNameUrlHandlerMapping example in Spring 2.5 Web MVC framework
;    BeanNameUrlHandlerMapping example in Spring 2.5 MVC framework... is. The HandlerMapping we can map incoming web request to the appropriate handler. When the user...; how to use BeanNameUrlHandlerMapping in your application. Spring provides
how many scenarios is having to developing web based application by using spring mvc.
how many scenarios is having to developing web based application by using spring mvc.  hello everyone, I want to know how many scenarios are available to developing web based application using spring. i know simple form
spring   hi how can we make spring bean as prototype how can we load applicationcontext in spring what is dependency injection
spring  how to upgrade from struts2 to spring
spring  javascript browse image in spring progrme
spring  Access JSP files in Spring
spring - Spring
spring  what is the use of spring  Hi Friend, Spring is grate framework for development of Enterprise grade applications. Spring.... Spring can be used to configure declarative transaction management, remote access
spring  sir how to access multiple jsp's in spring
spring   i am a beginner in java.. but i have to learn spring framework.. i know the core java concepts with some J2EE knowledge..can i learn spring without knowing anything about struts
spring  sir can you explain me the flow of sample example by using spring? thanks
Spring  What is AOP concept in spring? How AOP concept differ from DI concept
a complete project on spring web mvc using oracle database in netbeans ide 7.0
a complete project on spring web mvc using oracle database in netbeans ide 7.0  dear sir , i want a complete tutorial on the title matter.please sir help me . any full developped project based on shopping cart can
spring   package bean; public interface AccountsDAOI{ double... normally. i set the classpath=D:\java softwares\ST-IV\Spring\spring-framework-2 .5.1\dist\spring.jar;D:\java softwares\ST-IV\Spring\spring-framework-2.5.1\lib\c
Spring  I understand spring as dependency injection. It can avoid object creating and can directly inject values. But i am comfusing that Dependency... are created. By the same way i want to know how spring injected property
the following links:
the following links:
spring - Spring
spring  what is the use of HashTable concept in spring
spring - Spring
spring  what is Session Factory in spring
spring - Spring
spring  give me the explanation about spring>and give me the difference between spring and EJB 3.0 WHAT IS THE USAGE OF SPRING WHERE WE HAVE TO USE IT? GIVE ME ONE EXAMPLE
Spring 3 MVC hello world, Spring 3.0 Web MVC Example
Spring 3 MVC Hello World Example Getting stated with the Spring 3 MVC... first example in Spring MVC. After completing the tutorial you will be able to start developing small applications using Spring MVC. In this section we
spring - Spring
spring  Hi sir how compile spring application on jboss5.1.0 server how run spring application on jboss5.1.0 server thanks
spring - Spring
spring   hi, I need sample example user update profile using spring with hibernate and spring jsp. I need the sample code very urgently. Please... the following link:
spring - Spring
spring  how spring is light weight? please tell me this i want to know
SPRING - Spring
SPRING  In spring frame work when applicationcontext.xml will be load into the contianer i want answer plz replyyyyyy
spring - Spring
spring  i want to work in spring.i m new to spring. i have download the springframework 2.5.4 , i dont know how to use this in eclipse 3.3. i m... information.
spring - Spring
spring  what is the difference between spring and hibernate and ejb3.0  Hi mamatha, Spring provides hibernate template and it has many.... * Spring hibernateTemplate also throws RunTime exception compared to checkd
spring - Spring
spring  hi how to use work ioc in spring. Regards Venkatesan  Hi Friend, Please visit the following link: Here you will get the explanation of IOC and AOP. Thanks
spring - Spring
spring  sample code for formvalidation by using spring with javascript as presentation ex textboxes like dept id dept name Submit.../spring/userregistration.shtml Hope that it will be helpful for you. Thanks
spring - Spring
spring  i want to work in spring.i m new to spring. i have download the springframework 2.5.4 , i dont know how to use this in eclipse 3.3. i m using JBOSS server. help me plz
Adding Spring and Hibernate Capabilities
Spring and Hibernate Capabilities to our web application. So for this, we will have to add the spring and hibernate libraries and configuration files to the web...Adding Spring and Hibernate Capabilities   
Roseindia Spring Tutorial
Roseindia Spring tutorials provide you complete coverage of wide range of spring framework topics to help you create dynamic and advance web applications easily. At you will find plenty of spring tutorials for beginners
The Complete Spring Tutorial
you how you can integrate struts, spring and hibernate in your web... components can be used to developed MVC based web applications. Spring..., The tutorial given below describes you the way to make a spring web
Java Spring Online Training
one to have hands-on experience of spring in various web applications. Rose...Java Spring Online Training Java spring training online is sought... container. Spring is a wide spectrum framework designed to facilitate different
Spring Tutorial
and flexibility in developing web application using Spring MVC. Data accessibility...Spring Tutorial In this section we will read about the Spring framework. This section will describe about the various aspects of Spring framework
Spring Framework Tutorials
. Spring Framework provides support for JPA, Hibernate, Web services, Schedulers... of MVC based web applications. Spring Framework is embedded with many features...Spring Tutorials The Spring Framework is an open source Java platform, which
Spring or JDBC - Spring
Spring or JDBC  I am designing a simple java application... but was told to investigate using Spring framework. We use Spring framework for our online WEB applications and have 80 connections to manage but this Java app would