Easy learning with example program codes

eclipse maven spring MVC project

Eclipse maven spring mvc hello world:

Eclipse provides m2eclipse plugin to integrate Maven and Eclipse together.

Steps to create maven java web project in eclipse:

  1. In eclipse, click on File menu → New → Maven Project. Select maven-archetype-webapp template to create java project and Click on Next button.
  2. Now provide the group Id, artifact Id and Package. Click on Finish button. Complete directory structure and all files like web.xml file, pom.xml file, test case file etc will be created automatically.

Directory structure of the maven java web project:

Auto created index.jsp:

<h2>Hello World!</h2>

Edit Auto created web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="" 
	id="WebApp_ID" version="3.0">
   <display-name>Archetype Created Web Application</display-name>

Add dependencies in auto created pom.xml:

<project xmlns="" xmlns:xsi=""
  <name>SpringMVCHelloWorld Maven Webapp</name>
      <!-- Spring dependencies -->

Create an xml file dispatcher-servlet.xml file under the /WEB-INF/ directory.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""
	<context:component-scan base-package="com.programcreek.helloworld.controller" />
		<property name="prefix">
		<property name="suffix">

Here prefix property specifies the directory of jsp files (view files). The suffix property specifies the file extension of view files.

Create Spring Controller

Create the HelloWorldController ( under src/main/java/ directory:

package com.tutorialspointexamples.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
public class HelloWorldController {
	String message = "Hello ";
	public ModelAndView showMessage(
			@RequestParam(value = "name", required = false, 
			defaultValue = "World") String name) {
		ModelAndView mv = new ModelAndView("helloWorld");
		mv.addObject("message", message);
		mv.addObject("name", name);
		return mv;

The @RequestMapping annotation maps web requests to specific handler classes or handler methods.
The @RequestParam annotation is used for method parameter which should be bound to a web request parameter.
The new ModelAndView(“helloWorld”) refers to the target view.

Spring Tutorial

Spring framework.
Spring framework architecture.
Spring ioc container.
Spring bean.
Spring bean scopes.
Spring bean life cycle.
Spring callback methods.
Spring hello world.
Spring bean definition inheritance.
Spring bean definition template.
Spring dependency injection.
Spring constructor based injection.
Constructor injection type ambiguities.
Setter based dependency injection.
Spring dependency injection collections.
Spring autowire
Spring autowire by name
Spring autowire by type
Spring autowire by constructor
Spring JDBC tutorial
Spring JDBC Prepared Statement
Spring ResultSetExtractor
Spring RowMapper
Spring aop tutorial.
Spring AOP AspectJ Xml.
Spring AOP AspectJ Annotation.
Spring MVC tutorial.
Spring mvc framework.
Spring mvc configuration file.
Spring mvc hello world.
Spring MVC multiple controller.
Spring MVC login.
Spring mvc form handling.
Spring mvc exception handling.
Spring spel tutorial.
Spring spel hello world.
Spring spel operators.
Spring spel ternary operator.
Spring spel standardevaluationcontext.
Spring spel bean reference.
Spring spel method invocation.
Spring spel list, map.
Spring spel regex.
Maven Eclipse Spring
Spring boot overview
Spring boot architecture diagram
Spring boot components
Spring boot starter parent
Spring boot web app configuration
Run spring boot application
Spring boot change port
Spring boot change context path
Spring boot log sql statements
Spring boot hello world
Spring boot JSP
Spring boot thymeleaf
Spring boot with mysql
Spring security overview
Spring security architecture
Spring security maven dependency
Spring security xml
Spring security annotation
Spring security custom login xml
Spring security custom login annotation
Spring security form login
Spring security remember me
Spring security method level

Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at


We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on

Copyright © 2019 CodesJava Protection Status SiteMap Reference: Java Wiki