Programing deploying but give a 404 error Spring - java

I am learning spring and am making an practice program. I am getting the following a 404 error when I run the program. I will post the whole console output at the end. I am trying to implement the DAO method and create new pages with controllers. I will post the code so you understand what i am trying to say:
url
http://localhost:8080/SpringMVCTest/
offers controller
#Controller
public class OffersController {
public OffersController() {
System.out.println("loaded OffersController");
}
/*
* private OffersService offersService;
*
* #Autowired public void setOffersService(OffersService offersService) {
* this.offersService = offersService; }
*/
#RequestMapping("/offers")
public ModelAndView showOffers() {
System.out.println("in offers");
ModelAndView mv = new ModelAndView("/offers");
return mv;
}
#RequestMapping("/createoffer")
public ModelAndView createOffer() {
System.out.println("in createoffer");
ModelAndView mv = new ModelAndView("/createoffer");
return mv;
}
}
offer.jsp
<%# page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<c:forEach var="offers" items="${offer}">
<p><c:out value= ${offers}></c:out></p>
<p />
</c:forEach>
</body>
</html>
home.jsp controller
package com.learnspring.web.config;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
#Controller
public class HomeController {
#RequestMapping("/")
public ModelAndView showMessage() {
System.out.println("in controller");
ModelAndView mv = new ModelAndView("/home");
return mv;
}
}
home.jsp
<%# page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%# taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<p> Show current offers</p>
<p> Add a new offer</p>
</body>
</html>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>SpringMVCTest</display-name>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/offers-servlet.xml</param-value>
</context-param>
<!-- Database bean named offer and the DAO implementation -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:com/learnspring/web/config/dao-context.xml</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:com/learnspring/web/config/dao-context.xml
classpath:com/learnspring/web/config/service-context.xml
</param-value>
</context-param>
<!-- Servlet for offers -->
<servlet>
<description></description>
<display-name>offers</display-name>
<servlet-name>offers</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>offers</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!-- MySQL configuration -->
<description>Spring Database</description>
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/spring</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
service-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd">
<!-- handles OffersService.java -->
<context:annotation-config></context:annotation-config>
<context:component-scan base-package="com.learnspring.service"></context:component-scan>
</beans>
OffersService.java
package com.learnspring.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.learnspring.DAO.Offer;
import com.learnspring.DAO.OfferDAO;
#Service("offersService")
public class OffersService {
private OfferDAO offersDAO;
#Autowired
public void setOffersDAO(OfferDAO offersDAO) {
this.offersDAO = offersDAO;
}
public List<Offer> getCurrent() {
return offersDAO.getOffers();
}
}
console output
Mar 29, 2015 7:31:59 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:SpringMVCTest' did not find a matching property.
Mar 29, 2015 7:31:59 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version: Apache Tomcat/8.0.17
Mar 29, 2015 7:31:59 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built: Jan 9 2015 15:58:59 UTC
Mar 29, 2015 7:31:59 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number: 8.0.17.0
Mar 29, 2015 7:31:59 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name: Mac OS X
Mar 29, 2015 7:31:59 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version: 10.10.2
Mar 29, 2015 7:31:59 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture: x86_64
Mar 29, 2015 7:31:59 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JAVA_HOME: /Library/Java/JavaVirtualMachines/jdk1.8.0_31.jdk/Contents/Home/jre
Mar 29, 2015 7:31:59 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version: 1.8.0_31-b13
Mar 29, 2015 7:31:59 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor: Oracle Corporation
Mar 29, 2015 7:31:59 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE: /apache-tomcat-8.0.17
Mar 29, 2015 7:31:59 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME: /apache-tomcat-8.0.17
Mar 29, 2015 7:31:59 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=/apache-tomcat-8.0.17
Mar 29, 2015 7:31:59 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=/apache-tomcat-8.0.17
Mar 29, 2015 7:31:59 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=/apache-tomcat-8.0.17/webapps
Mar 29, 2015 7:31:59 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=/apache-tomcat-8.0.17/endorsed
Mar 29, 2015 7:31:59 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=UTF-8
Mar 29, 2015 7:31:59 PM 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: /Users/DrewJocham/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
Mar 29, 2015 7:31:59 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
Mar 29, 2015 7:31:59 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Mar 29, 2015 7:31:59 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-nio-8009"]
Mar 29, 2015 7:31:59 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Mar 29, 2015 7:31:59 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1248 ms
Mar 29, 2015 7:31:59 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Mar 29, 2015 7:31:59 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.0.17
Mar 29, 2015 7:32:01 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Mar 29, 2015 7:32:01 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Mar 29, 2015 7:32:01 PM org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization started
Mar 29, 2015 7:32:01 PM org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh
INFO: Refreshing Root WebApplicationContext: startup date [Sun Mar 29 19:32:01 CEST 2015]; root of context hierarchy
Mar 29, 2015 7:32:01 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [com/learnspring/web/config/dao-context.xml]
Mar 29, 2015 7:32:02 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [com/learnspring/web/config/service-context.xml]
It loaded DAO
Mar 29, 2015 7:32:02 PM org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization completed in 834 ms
Mar 29, 2015 7:32:02 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'offers'
Mar 29, 2015 7:32:02 PM org.springframework.web.servlet.DispatcherServlet initServletBean
INFO: FrameworkServlet 'offers': initialization started
Mar 29, 2015 7:32:02 PM org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh
INFO: Refreshing WebApplicationContext for namespace 'offers-servlet': startup date [Sun Mar 29 19:32:02 CEST 2015]; parent: Root WebApplicationContext
Mar 29, 2015 7:32:02 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/offers-servlet.xml]
loaded OffersController
Mar 29, 2015 7:32:03 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod
INFO: Mapped "{[/offers],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView com.learnspring.test.OffersController.showOffers()
Mar 29, 2015 7:32:03 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod
INFO: Mapped "{[/createoffer],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView com.learnspring.test.OffersController.createOffer()
Mar 29, 2015 7:32:03 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter initControllerAdviceCache
INFO: Looking for #ControllerAdvice: WebApplicationContext for namespace 'offers-servlet': startup date [Sun Mar 29 19:32:02 CEST 2015]; parent: Root WebApplicationContext
Mar 29, 2015 7:32:03 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter initControllerAdviceCache
INFO: Looking for #ControllerAdvice: WebApplicationContext for namespace 'offers-servlet': startup date [Sun Mar 29 19:32:02 CEST 2015]; parent: Root WebApplicationContext
Mar 29, 2015 7:32:03 PM org.springframework.web.servlet.DispatcherServlet initServletBean
INFO: FrameworkServlet 'offers': initialization completed in 1053 ms
Mar 29, 2015 7:32:03 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /apache-tomcat-8.0.17/webapps/docs
Mar 29, 2015 7:32:03 PM 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 29, 2015 7:32:03 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /apache-tomcat-8.0.17/webapps/docs has finished in 124 ms
Mar 29, 2015 7:32:03 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /apache-tomcat-8.0.17/webapps/examples
Mar 29, 2015 7:32:03 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Mar 29, 2015 7:32:03 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Mar 29, 2015 7:32:03 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /apache-tomcat-8.0.17/webapps/examples has finished in 297 ms
Mar 29, 2015 7:32:03 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /apache-tomcat-8.0.17/webapps/host-manager
Mar 29, 2015 7:32:04 PM 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 29, 2015 7:32:04 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /apache-tomcat-8.0.17/webapps/host-manager has finished in 132 ms
Mar 29, 2015 7:32:04 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /apache-tomcat-8.0.17/webapps/manager
Mar 29, 2015 7:32:04 PM 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 29, 2015 7:32:04 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /apache-tomcat-8.0.17/webapps/manager has finished in 97 ms
Mar 29, 2015 7:32:04 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /apache-tomcat-8.0.17/webapps/ROOT
Mar 29, 2015 7:32:04 PM 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 29, 2015 7:32:04 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /apache-tomcat-8.0.17/webapps/ROOT has finished in 102 ms
Mar 29, 2015 7:32:04 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
Mar 29, 2015 7:32:04 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-nio-8009"]
Mar 29, 2015 7:32:04 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 4440 ms
Mar 29, 2015 7:32:05 PM org.springframework.web.servlet.PageNotFound noHandlerFound
WARNING: No mapping found for HTTP request with URI [/SpringMVCTest/] in DispatcherServlet with name 'offers'
Mar 29, 2015 7:35:30 PM org.springframework.web.servlet.PageNotFound noHandlerFound
WARNING: No mapping found for HTTP request with URI [/SpringMVCTest/] in DispatcherServlet with name 'offers'
offers-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd">
<context:component-scan base-package="com.learnspring.test">
</context:component-scan>
<mvc:annotation-driven></mvc:annotation-driven>
<bean id="jspViewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsps"></property>
<property name="suffix" value=".jsp"></property>
</bean>
</beans>

You HomeController seems to be in com.learnspring.web.config and that is not being package scanned. I guess your OffersController is in the same package. Else you need to add that to package scanning as well. Hope this resolves the issue.So try changing the below
<context:component-scan base-package="com.learnspring.test">
</context:component-scan>
to
<context:component-scan base-package="com.learnspring.web.config">
</context:component-scan>

Related

AVERTISSEMENT: No mapping found for HTTP request with URI > "/springmvc/hello" in DispatcherServlet with name 'dispatcher'

I'm trying to code a hello world with spring MVC, but i recieve this error:
AVERTISSEMENT: No mapping found for HTTP request with URI
[/springmvc/hello] in DispatcherServlet with name 'dispatcher'
Image here
index.jsp :
<html>
<body>
<form action="/springmvc/hello">
Nom :<br> <input name="nom">
</form>
</body>
</html>
Web.xml :
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/dispatcher-servlet.xml</param-value>
<description>Description</description>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
dispatcher-servlet.xml :
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd">
<context:component-scan base-package="springmvc.controller"></context:component-scan>
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
</beans>
Hello.jsp:
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<br>
${message} :${nom}
</body>
</html>
HelloWorldController.java :
package springmvc.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.Mapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
#Controller
public class HelloWorldController {
String message = "Bienvenu dans mon premier exemple de spring mvc";
#RequestMapping("/hello")
public ModelAndView afficherMessager(#RequestParam(value="nom",defaultValue="World") String nom){
ModelAndView modelAndView=new ModelAndView("Hello World");
modelAndView.addAllObjects("nom",nom);
modelAndView.addAllObjects("message"message);
return modelAndView;
}
}
Log:
juil. 30, 2017 3:05:36 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
AVERTISSEMENT: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:springmvc' did not find a matching property.
juil. 30, 2017 3:05:36 AM org.apache.catalina.startup.VersionLoggerListener log
INFOS: Server version: Apache Tomcat/8.0.44
juil. 30, 2017 3:05:36 AM org.apache.catalina.startup.VersionLoggerListener log
INFOS: Server built: May 10 2017 17:21:09 UTC
juil. 30, 2017 3:05:36 AM org.apache.catalina.startup.VersionLoggerListener log
INFOS: Server number: 8.0.44.0
juil. 30, 2017 3:05:36 AM org.apache.catalina.startup.VersionLoggerListener log
INFOS: OS Name: Windows 10
juil. 30, 2017 3:05:36 AM org.apache.catalina.startup.VersionLoggerListener log
INFOS: OS Version: 10.0
juil. 30, 2017 3:05:36 AM org.apache.catalina.startup.VersionLoggerListener log
INFOS: Architecture: amd64
juil. 30, 2017 3:05:36 AM org.apache.catalina.startup.VersionLoggerListener log
INFOS: Java Home: C:\Program Files\Java\jdk1.8.0_131\jre
juil. 30, 2017 3:05:36 AM org.apache.catalina.startup.VersionLoggerListener log
INFOS: JVM Version: 1.8.0_131-b11
juil. 30, 2017 3:05:36 AM org.apache.catalina.startup.VersionLoggerListener log
INFOS: JVM Vendor: Oracle Corporation
juil. 30, 2017 3:05:36 AM org.apache.catalina.startup.VersionLoggerListener log
INFOS: CATALINA_BASE: C:\Users\Adem\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
juil. 30, 2017 3:05:36 AM org.apache.catalina.startup.VersionLoggerListener log
INFOS: CATALINA_HOME: C:\Users\Adem\Desktop\eclipse\apache-tomcat-8.0.44
juil. 30, 2017 3:05:36 AM org.apache.catalina.startup.VersionLoggerListener log
INFOS: Command line argument: -Dcatalina.base=C:\Users\Adem\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
juil. 30, 2017 3:05:36 AM org.apache.catalina.startup.VersionLoggerListener log
INFOS: Command line argument: -Dcatalina.home=C:\Users\Adem\Desktop\eclipse\apache-tomcat-8.0.44
juil. 30, 2017 3:05:36 AM org.apache.catalina.startup.VersionLoggerListener log
INFOS: Command line argument: -Dwtp.deploy=C:\Users\Adem\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
juil. 30, 2017 3:05:36 AM org.apache.catalina.startup.VersionLoggerListener log
INFOS: Command line argument: -Djava.endorsed.dirs=C:\Users\Adem\Desktop\eclipse\apache-tomcat-8.0.44\endorsed
juil. 30, 2017 3:05:36 AM org.apache.catalina.startup.VersionLoggerListener log
INFOS: Command line argument: -Dfile.encoding=Cp1252
juil. 30, 2017 3:05:36 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFOS: 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\jdk1.8.0_131\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre1.8.0_131/bin/server;C:/Program Files/Java/jre1.8.0_131/bin;C:/Program Files/Java/jre1.8.0_131/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\OpenVPN\bin;C:\Users\Adem\AppData\Local\Microsoft\WindowsApps;C:\Program Files\GPAC;C:\Program Files\GPAC;C:\Users\Adem\Desktop\eclipse;;.
juil. 30, 2017 3:05:36 AM org.apache.coyote.AbstractProtocol init
INFOS: Initializing ProtocolHandler ["http-nio-8080"]
juil. 30, 2017 3:05:37 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFOS: Using a shared selector for servlet write/read
juil. 30, 2017 3:05:37 AM org.apache.coyote.AbstractProtocol init
INFOS: Initializing ProtocolHandler ["ajp-nio-8009"]
juil. 30, 2017 3:05:37 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFOS: Using a shared selector for servlet write/read
juil. 30, 2017 3:05:37 AM org.apache.catalina.startup.Catalina load
INFOS: Initialization processed in 1534 ms
juil. 30, 2017 3:05:37 AM org.apache.catalina.core.StandardService startInternal
INFOS: Démarrage du service Catalina
juil. 30, 2017 3:05:37 AM org.apache.catalina.core.StandardEngine startInternal
INFOS: Starting Servlet Engine: Apache Tomcat/8.0.44
juil. 30, 2017 3:05:42 AM org.apache.jasper.servlet.TldScanner scanJars
INFOS: 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.
juil. 30, 2017 3:05:42 AM org.apache.catalina.core.ApplicationContext log
INFOS: No Spring WebApplicationInitializer types detected on classpath
juil. 30, 2017 3:05:42 AM org.apache.catalina.core.ApplicationContext log
INFOS: Initializing Spring root WebApplicationContext
juil. 30, 2017 3:05:42 AM org.springframework.web.context.ContextLoader initWebApplicationContext
INFOS: Root WebApplicationContext: initialization started
juil. 30, 2017 3:05:42 AM org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh
INFOS: Refreshing Root WebApplicationContext: startup date [Sun Jul 30 03:05:42 CEST 2017]; root of context hierarchy
juil. 30, 2017 3:05:42 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFOS: Loading XML bean definitions from ServletContext resource [/WEB-INF/dispatcher-servlet.xml]
juil. 30, 2017 3:05:45 AM org.springframework.web.context.ContextLoader initWebApplicationContext
INFOS: Root WebApplicationContext: initialization completed in 2638 ms
juil. 30, 2017 3:05:45 AM org.apache.catalina.core.ApplicationContext log
INFOS: Initializing Spring FrameworkServlet 'dispatcher'
juil. 30, 2017 3:05:45 AM org.springframework.web.servlet.DispatcherServlet initServletBean
INFOS: FrameworkServlet 'dispatcher': initialization started
juil. 30, 2017 3:05:45 AM org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh
INFOS: Refreshing WebApplicationContext for namespace 'dispatcher-servlet': startup date [Sun Jul 30 03:05:45 CEST 2017]; parent: Root WebApplicationContext
juil. 30, 2017 3:05:45 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFOS: Loading XML bean definitions from ServletContext resource [/WEB-INF/dispatcher-servlet.xml]
juil. 30, 2017 3:05:45 AM org.springframework.web.servlet.DispatcherServlet initServletBean
INFOS: FrameworkServlet 'dispatcher': initialization completed in 327 ms
juil. 30, 2017 3:05:45 AM org.apache.coyote.AbstractProtocol start
INFOS: Starting ProtocolHandler ["http-nio-8080"]
juil. 30, 2017 3:05:45 AM org.apache.coyote.AbstractProtocol start
INFOS: Starting ProtocolHandler ["ajp-nio-8009"]
juil. 30, 2017 3:05:45 AM org.apache.catalina.startup.Catalina start
INFOS: Server startup in 8334 ms
juil. 30, 2017 3:05:52 AM org.springframework.web.servlet.PageNotFound noHandlerFound
AVERTISSEMENT: No mapping found for HTTP request with URI [/springmvc/hello] in DispatcherServlet with name 'dispatcher'
Thanks
you use <mvc:annotation-driven/> in Dispatcher-servlet.

Spring MVC .jsp is not being created by ViewResolver automatically

im new to Spring MVC.when I run the project welcome.jsp gets open. then I fill in the form and press login. Its all as it should be until now but then I want the success.jsp to open if the userID is didem and the passqord is 123321 if not then welcome.jsp should reopen.. but what I actually get is 404 not found
because in the web browser the url link is like this: http://localhost:8080/CrunchifySpringMVCTutorial/welcome
Idk why the viewResolver doesnt put a .jsp at the end.. Any help would be appreciated ..
CrunchifyHelloWorld.java file:
package com.crunchify.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
#Controller
public class CrunchifyHelloWorld {
#RequestMapping(value = "/welcome", method = RequestMethod.GET)
public String showLoginForm() {
return "welcome";
}
#RequestMapping(value = "/welcome", method = RequestMethod.POST)
public String verifyLogin(#RequestParam String userID, #RequestParam String password){
ModelAndView model = new ModelAndView();
model.addObject("loginError", "Invalid Id AND/OR password");
if(userID == "didem" && password == "123321")
{
return "success";
}
return "redirect:/";
}
}
crunchify-servlet.xml file:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="com.crunchify.controller" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
<mvc:resources mapping="/resources/**" location="/resources/" />
<mvc:annotation-driven />
</beans>
web.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>CrunchifySpringMVCTutorial</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>crunchify</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>crunchify</servlet-name>
<url-pattern>/welcome.jsp</url-pattern>
<url-pattern>/welcome.html</url-pattern>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
</web-app>
welcome.jsp file:
<%# taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<!DOCTYPE html>
<html>
<head>
<!-- let's add tag spring:url -->
<spring:url value="/resources/crunchify.css" var="crunchifyCSS" />
<spring:url value="/resources/crunchify.js" var="crunchifyJS" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<link href="${crunchifyCSS}" rel="stylesheet" />
<script src="${crunchifyJS}"></script>
<!-- Finish adding tags -->
<title>Spring MVC Tutorial by Crunchify - Hello World Spring MVC Example</title>
<style type="text/css">
body {
background-image: url('http://cs-im.psn-web.net/Global/SIPPHONE/sipphone_net/download/UT670/wallpaper/gray_phone_background_plane.png');
}
</style>
</head>
<body>
<!-- webapp content goes here in the body -->
<div class = "container">
${loginError}
<div class = "form-group form" >
<form action = 'welcome' method = "POST">
<div>
<label>User name:</label>
<input type = "text" id = "userID" name = "userID" placeholder = "your username" class = "form-control">
</div>
<div>
<label>Password:</label>
<input type = "password" id = "password" name = "password" placeholder = "your password" class = "form-control">
</div>
<button id = "loginButton" class = "form-control">LOGIN</button>
</form>
</div>
</div>
</body>
</html>
success.jsp file:
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
CONGRATS. YOU SUCCESSFULLY LOGGED IN !
</body>
</html>
HERE IS THE EXPANDED STRUCTURE OF MY PROJECT
CONSOLE LOGS:
Jul 18, 2016 3:06:31 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:CrunchifySpringMVCTutorial' did not find a matching property.
Jul 18, 2016 3:06:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version: Apache Tomcat/8.0.36
Jul 18, 2016 3:06:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built: Jun 9 2016 13:55:50 UTC
Jul 18, 2016 3:06:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number: 8.0.36.0
Jul 18, 2016 3:06:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name: Windows 10
Jul 18, 2016 3:06:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version: 10.0
Jul 18, 2016 3:06:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture: amd64
Jul 18, 2016 3:06:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home: C:\dev\Java\jdk8\jre
Jul 18, 2016 3:06:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version: 1.8.0_74-b02
Jul 18, 2016 3:06:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor: Oracle Corporation
Jul 18, 2016 3:06:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE: C:\Users\User\Desktop\workspace2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
Jul 18, 2016 3:06:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME: C:\Program Files (x86)\apache-tomcat-8.0.36-windows-x64\apache-tomcat-8.0.36
Jul 18, 2016 3:06:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=C:\Users\User\Desktop\workspace2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
Jul 18, 2016 3:06:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=C:\Program Files (x86)\apache-tomcat-8.0.36-windows-x64\apache-tomcat-8.0.36
Jul 18, 2016 3:06:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=C:\Users\User\Desktop\workspace2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
Jul 18, 2016 3:06:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=C:\Program Files (x86)\apache-tomcat-8.0.36-windows-x64\apache-tomcat-8.0.36\endorsed
Jul 18, 2016 3:06:31 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=Cp1252
Jul 18, 2016 3:06:31 PM 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:\dev\Java\jdk8\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/dev/Java/jre8/bin/server;C:/dev/Java/jre8/bin;C:/dev/Java/jre8/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\dev\Java\jdk8\bin;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\gradle-2.2.1\bin;C:\Program Files\nodejs\;C:\Program Files (x86)\Git\bin;C:\Program Files (x86)\Git\cmd;C:\Users\User\AppData\Roaming\npm;C:\Users\User\eclipse\java-mars\eclipse;;.
Jul 18, 2016 3:06:31 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
Jul 18, 2016 3:06:31 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Jul 18, 2016 3:06:31 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-nio-8009"]
Jul 18, 2016 3:06:31 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Jul 18, 2016 3:06:31 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 493 ms
Jul 18, 2016 3:06:31 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jul 18, 2016 3:06:31 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.0.36
Jul 18, 2016 3:06:32 PM 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.
Jul 18, 2016 3:06:32 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Jul 18, 2016 3:06:32 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'crunchify'
Jul 18, 2016 3:06:32 PM org.springframework.web.servlet.DispatcherServlet initServletBean
INFO: FrameworkServlet 'crunchify': initialization started
Jul 18, 2016 3:06:32 PM org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh
INFO: Refreshing WebApplicationContext for namespace 'crunchify-servlet': startup date [Mon Jul 18 15:06:32 EEST 2016]; root of context hierarchy
Jul 18, 2016 3:06:32 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/crunchify-servlet.xml]
Jul 18, 2016 3:06:33 PM org.springframework.web.servlet.handler.SimpleUrlHandlerMapping registerHandler
INFO: Mapped URL path [/resources/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0'
Jul 18, 2016 3:06:33 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping register
INFO: Mapped "{[/welcome],methods=[POST]}" onto public java.lang.String com.crunchify.controller.CrunchifyHelloWorld.verifyLogin(java.lang.String,java.lang.String)
Jul 18, 2016 3:06:33 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping register
INFO: Mapped "{[/welcome],methods=[GET]}" onto public java.lang.String com.crunchify.controller.CrunchifyHelloWorld.showLoginForm()
Jul 18, 2016 3:06:33 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter initControllerAdviceCache
INFO: Looking for #ControllerAdvice: WebApplicationContext for namespace 'crunchify-servlet': startup date [Mon Jul 18 15:06:32 EEST 2016]; root of context hierarchy
Jul 18, 2016 3:06:33 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter initControllerAdviceCache
INFO: Looking for #ControllerAdvice: WebApplicationContext for namespace 'crunchify-servlet': startup date [Mon Jul 18 15:06:32 EEST 2016]; root of context hierarchy
Jul 18, 2016 3:06:33 PM org.springframework.web.servlet.DispatcherServlet initServletBean
INFO: FrameworkServlet 'crunchify': initialization completed in 875 ms
Jul 18, 2016 3:06:33 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
Jul 18, 2016 3:06:33 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-nio-8009"]
Jul 18, 2016 3:06:33 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1977 ms
Change your servlet mapping to following lines and check
<servlet-mapping>
<servlet-name>crunchify</servlet-name>
<url-pattern>/welcome.jsp</url-pattern>
<url-pattern>/welcome.html</url-pattern>
<url-pattern>/</url-pattern>
</servlet-mapping>
Chaneg below tag in web.xml and try once.
<servlet>
<servlet-name>crunchify</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/crunchify-servlet.xml </param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
what about return "redirect:/{welcome}"; as shown below.
#RequestMapping(value = "/welcome", method = RequestMethod.POST)
public String verifyLogin(#RequestParam String userID, #RequestParam String password){
ModelAndView model = new ModelAndView();
model.addObject("loginError", "Invalid Id AND/OR password");
if(userID == "didem" && password == "123321")
{
return "success";
}
return "redirect:/{welcome}";
}
}

Spring mapping failing: HTTP Status 404 (The requested resource is not available)

I know there are millions of possible solutions to this, and I tried many of them, but still no benefit at all.
I am trying to map a basic controller to a url and returning a JSP view. Its showing HTTP Status 404 with description The requested resource is not available. Please help.
Controller
package controllers;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
#Controller
public class HomePageController {
#RequestMapping(value = "/twenty-eight/index", method = RequestMethod.GET)
public ModelAndView homePage(HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse){
ModelAndView mav = new ModelAndView("HomePage");
System.out.println("Going to index page...");
return mav;
}
}
web.xml
<web-app id="WebApp_ID" version="2.4"
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">
<display-name>Spring Web MVC Application</display-name>
<servlet>
<servlet-name>dispatcher-servlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher-servlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
servlet-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="controllers" />
<mvc:annotation-driven />
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/views/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
JSP View
<!DOCTYPE html>
<html>
<head>
<title>HTML5 Login</title>
<link rel="stylesheet" href="CSS/normalize.css">
<link rel="stylesheet" href="CSS/style.css">
</head>
<body>
<h1>Working Fine</h1>
</body>
</html>
Tomcat logs
Aug 02, 2015 7:16:04 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Twenty Eight' did not find a matching property.
Aug 02, 2015 7:16:04 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version: Apache Tomcat/8.0.21
Aug 02, 2015 7:16:04 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built: Mar 23 2015 14:11:21 UTC
Aug 02, 2015 7:16:04 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number: 8.0.21.0
Aug 02, 2015 7:16:04 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name: Linux
Aug 02, 2015 7:16:04 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version: 3.16.0-44-generic
Aug 02, 2015 7:16:04 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture: amd64
Aug 02, 2015 7:16:04 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home: /usr/local/java/jdk1.8.0_40/jre
Aug 02, 2015 7:16:04 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version: 1.8.0_40-b26
Aug 02, 2015 7:16:04 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor: Oracle Corporation
Aug 02, 2015 7:16:04 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE: /home/kaustubh/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0
Aug 02, 2015 7:16:04 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME: /var/local/apache-tomcat-8.0.21
Aug 02, 2015 7:16:04 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=/home/kaustubh/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0
Aug 02, 2015 7:16:04 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=/var/local/apache-tomcat-8.0.21
Aug 02, 2015 7:16:04 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=/home/kaustubh/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps
Aug 02, 2015 7:16:04 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=/var/local/apache-tomcat-8.0.21/endorsed
Aug 02, 2015 7:16:04 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=UTF-8
Aug 02, 2015 7:16:04 PM 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: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
Aug 02, 2015 7:16:04 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
Aug 02, 2015 7:16:04 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Aug 02, 2015 7:16:04 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-nio-8009"]
Aug 02, 2015 7:16:04 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Aug 02, 2015 7:16:04 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 989 ms
Aug 02, 2015 7:16:04 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Aug 02, 2015 7:16:04 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.0.21
Aug 02, 2015 7:16:06 PM 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.
Aug 02, 2015 7:16:06 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Aug 02, 2015 7:16:07 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'dispatcher-servlet'
Aug 02, 2015 7:16:07 PM org.springframework.web.servlet.DispatcherServlet initServletBean
INFO: FrameworkServlet 'dispatcher-servlet': initialization started
Aug 02, 2015 7:16:07 PM org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh
INFO: Refreshing WebApplicationContext for namespace 'dispatcher-servlet-servlet': startup date [Sun Aug 02 19:16:07 IST 2015]; root of context hierarchy
Aug 02, 2015 7:16:07 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/servlet-context.xml]
Aug 02, 2015 7:16:08 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping register
INFO: Mapped "{[/twenty-eight/index],methods=[GET]}" onto public org.springframework.web.servlet.ModelAndView controllers.HomePageController.homePage(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
Aug 02, 2015 7:16:09 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter initControllerAdviceCache
INFO: Looking for #ControllerAdvice: WebApplicationContext for namespace 'dispatcher-servlet-servlet': startup date [Sun Aug 02 19:16:07 IST 2015]; root of context hierarchy
Aug 02, 2015 7:16:09 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter initControllerAdviceCache
INFO: Looking for #ControllerAdvice: WebApplicationContext for namespace 'dispatcher-servlet-servlet': startup date [Sun Aug 02 19:16:07 IST 2015]; root of context hierarchy
Aug 02, 2015 7:16:09 PM org.springframework.web.servlet.DispatcherServlet initServletBean
INFO: FrameworkServlet 'dispatcher-servlet': initialization completed in 1772 ms
Aug 02, 2015 7:16:09 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
Aug 02, 2015 7:16:09 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-nio-8009"]
Aug 02, 2015 7:16:09 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 4680 ms
Project Structure
https://drive.google.com/open?id=0B2s3KIDgKxy8RlVqZmdneW9WV1U

Simple spring framework program not running and I cannot figure out why

I have already had help with this program and got it to work. I then decided I would do it again my scratch to make sure I understood but I got the same issues. The hard part is the console is not printing out any errors.
console:
Mar 22, 2015 9:07:09 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:LearnSpringMVC' did not find a matching property.
Mar 22, 2015 9:07:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version: Apache Tomcat/8.0.17
Mar 22, 2015 9:07:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built: Jan 9 2015 15:58:59 UTC
Mar 22, 2015 9:07:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number: 8.0.17.0
Mar 22, 2015 9:07:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name: Mac OS X
Mar 22, 2015 9:07:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version: 10.10.2
Mar 22, 2015 9:07:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture: x86_64
Mar 22, 2015 9:07:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JAVA_HOME: /Library/Java/JavaVirtualMachines/jdk1.8.0_31.jdk/Contents/Home/jre
Mar 22, 2015 9:07:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version: 1.8.0_31-b13
Mar 22, 2015 9:07:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor: Oracle Corporation
Mar 22, 2015 9:07:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE: /apache-tomcat-8.0.17
Mar 22, 2015 9:07:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME: /apache-tomcat-8.0.17
Mar 22, 2015 9:07:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=/apache-tomcat-8.0.17
Mar 22, 2015 9:07:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=/apache-tomcat-8.0.17
Mar 22, 2015 9:07:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=/apache-tomcat-8.0.17/wtpwebapps
Mar 22, 2015 9:07:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=/apache-tomcat-8.0.17/endorsed
Mar 22, 2015 9:07:09 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=UTF-8
Mar 22, 2015 9:07:09 PM 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: /Users/DrewJocham/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
Mar 22, 2015 9:07:09 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
Mar 22, 2015 9:07:09 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Mar 22, 2015 9:07:09 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-nio-8009"]
Mar 22, 2015 9:07:09 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Mar 22, 2015 9:07:09 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1890 ms
Mar 22, 2015 9:07:09 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Mar 22, 2015 9:07:09 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.0.17
Mar 22, 2015 9:07:11 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Mar 22, 2015 9:07:12 PM org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [216] milliseconds.
Mar 22, 2015 9:07:12 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /apache-tomcat-8.0.17/webapps/docs
Mar 22, 2015 9:07:12 PM 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, 2015 9:07:12 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /apache-tomcat-8.0.17/webapps/docs has finished in 194 ms
Mar 22, 2015 9:07:12 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /apache-tomcat-8.0.17/webapps/examples
Mar 22, 2015 9:07:13 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Mar 22, 2015 9:07:13 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Mar 22, 2015 9:07:13 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /apache-tomcat-8.0.17/webapps/examples has finished in 750 ms
Mar 22, 2015 9:07:13 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /apache-tomcat-8.0.17/webapps/host-manager
Mar 22, 2015 9:07:13 PM 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, 2015 9:07:13 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /apache-tomcat-8.0.17/webapps/host-manager has finished in 164 ms
Mar 22, 2015 9:07:13 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /apache-tomcat-8.0.17/webapps/manager
Mar 22, 2015 9:07:13 PM 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, 2015 9:07:13 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /apache-tomcat-8.0.17/webapps/manager has finished in 172 ms
Mar 22, 2015 9:07:13 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /apache-tomcat-8.0.17/webapps/ROOT
Mar 22, 2015 9:07:13 PM 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, 2015 9:07:13 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /apache-tomcat-8.0.17/webapps/ROOT has finished in 147 ms
Mar 22, 2015 9:07:13 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
Mar 22, 2015 9:07:13 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-nio-8009"]
Mar 22, 2015 9:07:13 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 4068 ms
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
id="WebApp_ID"
version="3.1">
<display-name>SpringJSP</display-name>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:offers-servlet.xml</param-value>
</context-param>
<servlet>
<servlet-name>offers</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>offers</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
home.jsp file
<%# page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
Hello from JSP...
</body>
</html>
OffersController.java
package com.learnspring.controller;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
#Controller
#RequestMapping(value = "/")
public class OffersController {
#RequestMapping(method = RequestMethod.GET)
public ModelAndView homeGet(HttpServletRequest request) {
System.out.println("Check mapping");
ModelAndView model = new ModelAndView("home");
return model;
}
}
offers-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd">
<context:component-scan base-package="com.learnspring.controller"></context:component-scan>
<mvc:annotation-driven></mvc:annotation-driven>
<mvc:default-servlet-handler />
<bean
id="jspViewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property
name="prefix"
value="/WEB-INF/jsps/"></property>
<property
name="suffix"
value=".jsp"></property>
</bean>
</beans>
I do not know why this keeps happening to me. Can anyone help out? I checked the working code line by line and it was correct and it still works.
your application context xml file name should be offers-servlet.xml in stead of offers.xml

No error in apache but I get a 404 error

I have been at this for a day now and cannot understand why it is not working. I followed a tutorial, read the spring documentation and still do not understand, even better there are on errors to go off of.
Mar 19, 2015 6:42:04 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Spring with JSP' did not find a matching property.
Mar 19, 2015 6:42:04 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:JavaSpringMVCTake2' did not find a matching property.
Mar 19, 2015 6:42:04 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version: Apache Tomcat/8.0.17
Mar 19, 2015 6:42:04 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built: Jan 9 2015 15:58:59 UTC
Mar 19, 2015 6:42:04 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number: 8.0.17.0
Mar 19, 2015 6:42:04 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name: Mac OS X
Mar 19, 2015 6:42:04 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version: 10.10.2
Mar 19, 2015 6:42:04 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture: x86_64
Mar 19, 2015 6:42:04 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JAVA_HOME: /Library/Java/JavaVirtualMachines/jdk1.8.0_31.jdk/Contents/Home/jre
Mar 19, 2015 6:42:04 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version: 1.8.0_31-b13
Mar 19, 2015 6:42:04 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor: Oracle Corporation
Mar 19, 2015 6:42:04 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE: /Users/DrewJocham/Documents/caveOfprograming/.metadata/.plugins/org.eclipse.wst.server.core/tmp0
Mar 19, 2015 6:42:04 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME: /apache-tomcat-8.0.17
Mar 19, 2015 6:42:04 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=/Users/DrewJocham/Documents/caveOfprograming/.metadata/.plugins/org.eclipse.wst.server.core/tmp0
Mar 19, 2015 6:42:04 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=/apache-tomcat-8.0.17
Mar 19, 2015 6:42:04 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=/Users/DrewJocham/Documents/caveOfprograming/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps
Mar 19, 2015 6:42:04 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=/apache-tomcat-8.0.17/endorsed
Mar 19, 2015 6:42:04 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=UTF-8
Mar 19, 2015 6:42:04 PM 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: /Users/DrewJocham/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
Mar 19, 2015 6:42:04 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
Mar 19, 2015 6:42:05 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Mar 19, 2015 6:42:05 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-nio-8009"]
Mar 19, 2015 6:42:05 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Mar 19, 2015 6:42:05 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 2855 ms
Mar 19, 2015 6:42:05 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Mar 19, 2015 6:42:05 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.0.17
Mar 19, 2015 6:42:06 PM 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 19, 2015 6:42:06 PM org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [223] milliseconds.
Mar 19, 2015 6:42:08 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Mar 19, 2015 6:42:08 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'offers'
Mar 19, 2015 6:42:08 PM org.springframework.web.servlet.DispatcherServlet initServletBean
INFO: FrameworkServlet 'offers': initialization started
Mar 19, 2015 6:42:08 PM org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh
INFO: Refreshing WebApplicationContext for namespace 'offers-servlet': startup date [Thu Mar 19 18:42:08 CET 2015]; root of context hierarchy
Mar 19, 2015 6:42:08 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/offers-servlet.xml]
Mar 19, 2015 6:42:10 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod
INFO: Mapped "{[/],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.learnspring.controller.OffersController.showHome()
Mar 19, 2015 6:42:10 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter initControllerAdviceCache
INFO: Looking for #ControllerAdvice: WebApplicationContext for namespace 'offers-servlet': startup date [Thu Mar 19 18:42:08 CET 2015]; root of context hierarchy
Mar 19, 2015 6:42:10 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter initControllerAdviceCache
INFO: Looking for #ControllerAdvice: WebApplicationContext for namespace 'offers-servlet': startup date [Thu Mar 19 18:42:08 CET 2015]; root of context hierarchy
Mar 19, 2015 6:42:10 PM org.springframework.web.servlet.DispatcherServlet initServletBean
INFO: FrameworkServlet 'offers': initialization completed in 2159 ms
Mar 19, 2015 6:42:12 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Mar 19, 2015 6:42:12 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
Mar 19, 2015 6:42:12 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-nio-8009"]
Mar 19, 2015 6:42:12 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 6971 ms
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
id="WebApp_ID" version="3.1">
<display-name>JavaSpringMVCTake2</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<description></description>
<display-name>offers</display-name>
<servlet-name>offers</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>offers</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
controller Servlet
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd">
<context:component-scan base-package="com.learnspring.controller"></context:component-scan>
<mvc:annotation-driven></mvc:annotation-driven>
<bean id="jspViewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsps/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
</beans>
controller class
package com.learnspring.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
#Controller
public class OffersController {
#RequestMapping("/")
public String showHome() {
return "home";
}
}
home.jsp
<%# page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
Hello World from JSP...
</body>
</html>
offers-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd">
<context:component-scan base-package="com.learnspring.controller"></context:component-scan>
<mvc:annotation-driven></mvc:annotation-driven>
<mvc:default-servlet-handler />
<bean
id="jspViewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property
name="prefix"
value="/WEB-INF/jsps/"></property>
<property
name="suffix"
value=".jsp"></property>
</bean>
</beans>
So your web.xml configuration need below configuration, add belows.
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
id="WebApp_ID"
version="3.1">
<display-name>SpringJSP</display-name>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:offers-servlet.xml</param-value>
</context-param>
<servlet>
<servlet-name>offers</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>offers</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
OffersController.java
package com.learnspring.controller;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
#Controller
#RequestMapping(value = "/")
public class OffersController {
#RequestMapping(method = RequestMethod.GET)
public ModelAndView homeGet(HttpServletRequest request) {
System.out.println("Check mapping");
ModelAndView model = new ModelAndView("home");
return model;
}
}
Final notes:
Use Spring webmvc jar. checkpom.xml all you need is this.
Add to offers-servlet.xml . Check below notes for
-Don't use run on server inside eclipse and make the request to http://localhost:8080/offers/ from a browser.
The caveat to overriding the "/" Servlet mapping is that the
RequestDispatcher for the default Servlet must be retrieved by name
rather than by path. The DefaultServletHttpRequestHandler will attempt
to auto-detect the default Servlet for the container at startup time,
using a list of known names for most of the major Servlet containers
(including Tomcat, Jetty, GlassFish, JBoss, Resin, WebLogic, and
WebSphere).
Resource

Categories

Resources