Welcome to Spring MVC Example. Sometime back in Spring MVC Tutorial, I explained how to create Spring MVC application using Spring Tool Suite. But today, I will be creating a basic hello world spring MVC application using maven and Eclipse.
Spring MVC is based on Model-View-Controller architecture. Below image shows Spring MVC architecture at a high level. DispatcherServlet
is the front controller class to take all requests and start processing them. We have to configure it in web.xml file. It’s job is to pass request to appropriate controller class and send the response back when view pages have rendered the response page. HomeController.java
will be the single controller class in our spring mvc example application. home.jsp
, user.jsp
are the view pages in our spring mvc hello world example application. User.java
will be the only model class we will have in our spring mvc example web application.
Below image shows our Spring MVC example project in Eclipse. Let’s get started and create our project right from the scratch.
Since it’s a web application and we want to use maven for dependencies management, first of all we have to create a dynamic web application and then convert it to a maven project. Below images show how to do this and get our project skeleton structure ready. Right click on the project explorer window and click on “New -> Dynamic Web Project” as shown in below image. Provide name as “spring-mvc-example” in the next popup page, rest of the things should not required to be changed. On next page, provide the source folder as “src/main/java”. You might have to remove “src” folder from the list before adding this. Next is the web module page, provide the context root of application as “spring-mvc-example” and make sure to check “Generate web.xml deployment descriptor” option. Click on Finish and you will have a new Dynamic Web Project in your eclipse project explorer.
We want to use maven for easily manage our spring mvc dependencies. So let’s convert our web project to maven. Right click on the project and select “Configure -> Convert to Maven Project”. Next provide the pom.xml configurations as shown below. Our maven web application project skeleton code is ready. Now we can start making changes to it and create our spring mvc hello world example application.
We need to add spring-web and spring-webmvc dependencies in pom.xml, also add servlet-api, jsp-api and jstl dependencies. Our final pom.xml file will be like below.
<project xmlns="https://maven.apache.org/POM/4.0.0" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.journaldev.spring.mvc</groupId>
<artifactId>spring-mvc-example</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>Spring MVC Example</name>
<description>Spring MVC Hello World Example</description>
<!-- Add Spring Web and MVC dependencies -->
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.3.9.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.3.9.RELEASE</version>
</dependency>
<!-- Servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
</configuration>
</plugin>
</plugins>
<finalName>${project.artifactId}</finalName> <!-- added to remove Version from WAR file -->
</build>
</project>
Notice the finalName
configuration in build, so that our WAR file name doesn’t have version details. When the project is build by Eclipse, you will notice all the jars showing up in maven dependencies section.
We have to add Spring MVC framework to our web application, for that we need to configure DispatcherServlet
in web.xml as shown below.
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xmlns="https://java.sun.com/xml/ns/javaee" xsi:schemaLocation="https://java.sun.com/xml/ns/javaee https://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>spring-mvc-example</display-name>
<!-- Add Spring MVC DispatcherServlet as front controller -->
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
contextConfigLocation
init-param is used to provide the location of spring bean configuration file.
Next step is to create spring bean configuration file spring-servlet.xml
as shown below.
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="https://www.springframework.org/schema/mvc"
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xmlns:beans="https://www.springframework.org/schema/beans"
xmlns:context="https://www.springframework.org/schema/context"
xsi:schemaLocation="https://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd
https://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
https://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">
<!-- DispatcherServlet Context: defines this servlet's request-processing
infrastructure -->
<!-- Enables the Spring MVC @Controller programming model -->
<annotation-driven />
<context:component-scan base-package="com.journaldev.spring" />
<!-- Resolves views selected for rendering by @Controllers to .jsp resources
in the /WEB-INF/views directory -->
<beans:bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
</beans:beans>
There are three important configurations.
annotation-driven
tells DispatcherServlet to look for Controller classes using @Controller
annotation.context:component-scan
tells DispatcherServlet where to look for controller classes.InternalResourceViewResolver
bean configuration to specify location of view pages and suffix used. Controller class methods return name of the view page and then suffix is added to figure out the view page to use for rendering the response.We have a single controller class to respond for two URIs - “/” for home page and “/user” for user page.
package com.journaldev.spring.controller;
import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.journaldev.spring.model.User;
@Controller
public class HomeController {
/**
* Simply selects the home view to render by returning its name.
*/
@RequestMapping(value = "/", method = RequestMethod.GET)
public String home(Locale locale, Model model) {
System.out.println("Home Page Requested, locale = " + locale);
Date date = new Date();
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
String formattedDate = dateFormat.format(date);
model.addAttribute("serverTime", formattedDate);
return "home";
}
@RequestMapping(value = "/user", method = RequestMethod.POST)
public String user(@Validated User user, Model model) {
System.out.println("User Page Requested");
model.addAttribute("userName", user.getUserName());
return "user";
}
}
Note that for simplicity, I have not used any logging framework such as log4j.
We have a simple model class with a single variable and it’s getter-setter methods. It’s a simple POJO class.
package com.journaldev.spring.model;
public class User {
private String userName;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
}
We have two view pages as defined below. home.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="https://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page session="false"%>
<html>
<head>
<title>Home</title>
</head>
<body>
<h1>Hello world!</h1>
<P>The time on the server is ${serverTime}.</p>
<form action="user" method="post">
<input type="text" name="userName"><br> <input
type="submit" value="Login">
</form>
</body>
</html>
user.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "https://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>User Home Page</title>
</head>
<body>
<h3>Hi ${userName}</h3>
</body>
</html>
Notice that Spring MVC takes care of mapping form variables to model class variables, that’s why we have same variable name in both places. That’s it, our spring mvc example project is ready to de deployed and test.
We can use Eclipse export as WAR file option to deploy it directly to any running tomcat server webapps directory. However you can also use command line to build the project and then copy it into your favourite servlet container deployment directory.
Once the spring mvc project is deployed, we can access the home page at https://localhost:8080/spring-mvc-example/
. Change the tomcat port and context-root accordingly. That’s all for Spring MVC example, I have tried to keep it as simple as possible. But still if you face any issues then please let me know through comments and I will try to help you out. You can download the final spring mvc example project from below link.
Download Spring MVC Example Project
References: Official Page
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
While we believe that this content benefits our community, we have not yet thoroughly reviewed it. If you have any suggestions for improvements, please let us know by clicking the “report an issue“ button at the bottom of the tutorial.
I am getting Http:404 Error. please help. Thanks.
- Udit
user.getUserName() when is user.setUserName() called . how the value is set?
- Baburam Neupane
Hi , Getting exception org.springframework.web.servlet.PageNotFound.noHandlerFound No mapping found for HTTP request with URI [/KATFIN/] in DispatcherServlet with name ‘spring’
- siddhartha Jain
its asking for username and password and localhost8080 is not working
- manjunatha
i am getting this type of error what i do? type Exception report message Servlet.init() for servlet spring threw exception description The server encountered an internal error that prevented it from fulfilling this request. exception javax.servlet.ServletException: Servlet.init() for servlet spring threw exception org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502) org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1132) org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684) org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1539) org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1495) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) java.lang.Thread.run(Thread.java:748) root cause org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/spring-servlet.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/spring-servlet.xml] org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:344) org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304) org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181) org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217) org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188) org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125) org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94) org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129) org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:614) org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:515) org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668) org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634) org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682) org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553) org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494) org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:171) javax.servlet.GenericServlet.init(GenericServlet.java:158) org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502) org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1132) org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684) org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1539) org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1495) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) java.lang.Thread.run(Thread.java:748) root cause java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/spring-servlet.xml] org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:141) org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:330) org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304) org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181) org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217) org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188) org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125) org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94) org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129) org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:614) org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:515) org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668) org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634) org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682) org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553) org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494) org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:171) javax.servlet.GenericServlet.init(GenericServlet.java:158) org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502) org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1132) org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684) org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1539) org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1495) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) java.lang.Thread.run(Thread.java:748) note The full stack trace of the root cause is available in the Apache Tomcat/8.0.47 logs.
- Arulselvan
I tried with many projects but i am getting the same error can you please help me with this? WARNING: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [109] milliseconds. WARNING: [SetContextPropertiesRule]{Context} Setting property ‘source’ to ‘org.eclipse.jst.jee.server:SpringsMVC’ did not find a matching property.
- ishwarya
Mar 22, 2018 10:41:27 AM org.apache.catalina.startup.VersionLoggerListener log INFO: Server version: Apache Tomcat/9.0.5 Mar 22, 2018 10:41:27 AM org.apache.catalina.startup.VersionLoggerListener log INFO: Server built: Feb 6 2018 21:42:23 UTC Mar 22, 2018 10:41:27 AM org.apache.catalina.startup.VersionLoggerListener log INFO: Server number: 9.0.5.0 Mar 22, 2018 10:41:27 AM org.apache.catalina.startup.VersionLoggerListener log INFO: OS Name: Windows 10 Mar 22, 2018 10:41:27 AM org.apache.catalina.startup.VersionLoggerListener log INFO: OS Version: 10.0 Mar 22, 2018 10:41:27 AM org.apache.catalina.startup.VersionLoggerListener log INFO: Architecture: amd64 Mar 22, 2018 10:41:27 AM org.apache.catalina.startup.VersionLoggerListener log INFO: Java Home: C:\Program Files\Java\jre-9.0.4 Mar 22, 2018 10:41:27 AM org.apache.catalina.startup.VersionLoggerListener log INFO: JVM Version: 9.0.4+11 Mar 22, 2018 10:41:27 AM org.apache.catalina.startup.VersionLoggerListener log INFO: JVM Vendor: Oracle Corporation Mar 22, 2018 10:41:27 AM org.apache.catalina.startup.VersionLoggerListener log INFO: CATALINA_BASE: C:\Users\ishwa\eclipse\.metadata\.plugins\org.eclipse.wst.server.core\tmp0 Mar 22, 2018 10:41:27 AM org.apache.catalina.startup.VersionLoggerListener log INFO: CATALINA_HOME: C:\Users\ishwa\Downloads\apache-tomcat-9.0.5-windows-x64\apache-tomcat-9.0.5 Mar 22, 2018 10:41:27 AM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Dcatalina.base=C:\Users\ishwa\eclipse\.metadata\.plugins\org.eclipse.wst.server.core\tmp0 Mar 22, 2018 10:41:27 AM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Dcatalina.home=C:\Users\ishwa\Downloads\apache-tomcat-9.0.5-windows-x64\apache-tomcat-9.0.5 Mar 22, 2018 10:41:27 AM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Dwtp.deploy=C:\Users\ishwa\eclipse\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps Mar 22, 2018 10:41:27 AM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Dfile.encoding=Cp1252 Mar 22, 2018 10:41:27 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jre-9.0.4\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\oraclexe\app\oracle\product\11.2.0\server\bin;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Git\cmd;C:\Program Files\nodejs\;C:\Program Files (x86)\Intel\Intel® Management Engine Components\DAL;C:\Program Files\Intel\Intel® Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel® Management Engine Components\IPT;C:\Program Files\Intel\Intel® Management Engine Components\IPT;C:\Program Files\Java\jdk-9.0.1\bin;C:\Users\ishwa\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Microsoft VS Code\bin;C:\Users\ishwa\AppData\Roaming\npm;.] Mar 22, 2018 10:41:27 AM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler [“http-nio-8091”] Mar 22, 2018 10:41:27 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector INFO: Using a shared selector for servlet write/read Mar 22, 2018 10:41:27 AM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler [“ajp-nio-8009”] Mar 22, 2018 10:41:27 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector INFO: Using a shared selector for servlet write/read Mar 22, 2018 10:41:27 AM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 1082 ms Mar 22, 2018 10:41:27 AM org.apache.catalina.core.StandardService startInternal INFO: Starting service [Catalina] Mar 22, 2018 10:41:27 AM org.apache.catalina.core.StandardEngine startInternal INFO: Starting Servlet Engine: Apache Tomcat/9.0.5 Mar 22, 2018 10:41:28 AM org.apache.jasper.servlet.TldScanner scanJars INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. Mar 22, 2018 10:41:28 AM org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom WARNING: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [109] milliseconds. Mar 22, 2018 10:41:28 AM org.apache.catalina.startup.HostConfig deployDescriptor INFO: Deploying configuration descriptor [C:\Users\ishwa\eclipse\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf\Catalina\localhost\SpringsMVC.xml] Mar 22, 2018 10:41:28 AM org.apache.catalina.startup.SetContextPropertiesRule begin WARNING: [SetContextPropertiesRule]{Context} Setting property ‘source’ to ‘org.eclipse.jst.jee.server:SpringsMVC’ did not find a matching property. Mar 22, 2018 10:41:30 AM org.apache.jasper.servlet.TldScanner scanJars INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. Mar 22, 2018 10:41:30 AM org.apache.catalina.core.ApplicationContext log INFO: No Spring WebApplicationInitializer types detected on classpath Mar 22, 2018 10:41:30 AM org.apache.catalina.core.ApplicationContext log INFO: Initializing Spring FrameworkServlet ‘spring’ Mar 22, 2018 10:41:30 AM org.springframework.web.servlet.DispatcherServlet initServletBean INFO: FrameworkServlet ‘spring’: initialization started Mar 22, 2018 10:41:30 AM org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh INFO: Refreshing WebApplicationContext for namespace ‘spring-servlet’: startup date [Thu Mar 22 10:41:30 EDT 2018]; root of context hierarchy Mar 22, 2018 10:41:30 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/spring-servlet.xml] Mar 22, 2018 10:41:32 AM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping register INFO: Mapped “{[/user],methods=[POST]}” onto public java.lang.String com.journaldev.spring.controller.HomeController.user(com.journaldev.spring.model.User,org.springframework.ui.Model) Mar 22, 2018 10:41:32 AM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping register INFO: Mapped “{[/],methods=[GET]}” onto public java.lang.String com.journaldev.spring.controller.HomeController.home(java.util.Locale,org.springframework.ui.Model) Mar 22, 2018 10:41:32 AM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter initControllerAdviceCache INFO: Looking for @ControllerAdvice: WebApplicationContext for namespace ‘spring-servlet’: startup date [Thu Mar 22 10:41:30 EDT 2018]; root of context hierarchy Mar 22, 2018 10:41:32 AM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter initControllerAdviceCache INFO: Looking for @ControllerAdvice: WebApplicationContext for namespace ‘spring-servlet’: startup date [Thu Mar 22 10:41:30 EDT 2018]; root of context hierarchy Mar 22, 2018 10:41:32 AM org.springframework.web.servlet.DispatcherServlet initServletBean INFO: FrameworkServlet ‘spring’: initialization completed in 2164 ms Mar 22, 2018 10:41:32 AM org.apache.catalina.startup.HostConfig deployDescriptor INFO: Deployment of configuration descriptor [C:\Users\ishwa\eclipse\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf\Catalina\localhost\SpringsMVC.xml] has finished in [4,243] ms Mar 22, 2018 10:41:32 AM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler [“http-nio-8091”] Mar 22, 2018 10:41:32 AM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler [“ajp-nio-8009”] Mar 22, 2018 10:41:32 AM org.apache.catalina.startup.Catalina start INFO: Server startup in 4971 ms Home Page Requested, locale = en_US
- ishwarya
how to import you download project in eclipse
- sathish.d
Hello, I am getting multiple markers: requestMethod can not be resolved to a variable requestMapping can not to be resolved to a type any idea? Thanks. mj
- mj
Hi Pankaj, this is a nice artical. Thanks for sharing.
- Rajendra