spring web
1 Answer(s)      5 years and 5 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 [email protected] 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
Maven dependency for Spring Web MVC 4.0.1.RELEASE
Maven dependency for Spring Web MVC 4.0.1.RELEASE  Hi, What is the Maven dependency for Spring Web MVC 4.0.1.RELEASE? Thanks   Hi, You...; <groupId>org.springframework</groupId> <artifactId>spring
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
How to make Spring web Login form?
Developing Login Form in Spring Web - Create form for user to input login... based application in Spring Web  and validate the form using...: How to make Login Form in Spring MVC? To make the Spring Login form we have
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  Access JSP files in Spring
spring  javascript browse image in spring progrme
spring  how to upgrade from struts2 to spring
How to make Simple form in Spring web?
" /> Finally we have to load the Spring Context on the web application... will learn how to create Spring web Login form? Download source code...Web application uses the HTML standard to make the form which runs in browser
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  What is AOP concept in spring? How AOP concept differ from DI concept
spring  sir can you explain me the flow of sample example by using spring? thanks
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
the following links: