dimanche 29 mars 2015

No mapping found for HTTP request with URI [/SpringMVCTest/] in DispatcherServlet with name 'offers'

I am learning spring and am making an practice program. I am getting the following warning: No mapping found for HTTP request with URI [/SpringMVCTest/] in DispatcherServlet with name 'offers'


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 coe 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://ift.tt/QfKAz6" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://ift.tt/kTyqzh">
<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://ift.tt/1cjm3bo" prefix="sql"%>
<%@ taglib uri="http://ift.tt/QfKAz6" prefix="c"%>


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://ift.tt/kTyqzh">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>

<p> <a href="${pageConext.request.contextPath}/offer">Show current offers</a></p>
<p> <a href="${pageConext.request.contextPath}/createOffer">Add a new offer</a></p>

</body>
</html>


web.xml



<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://ift.tt/ra1lAU"
xmlns="http://ift.tt/nSRXKP"
xsi:schemaLocation="http://ift.tt/nSRXKP http://ift.tt/1eWqHMP"
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://ift.tt/GArMu6"
xmlns:xsi="http://ift.tt/ra1lAU"
xmlns:context="http://ift.tt/GArMu7"
xsi:schemaLocation="http://ift.tt/GArMu6 http://ift.tt/1jdM0fG
http://ift.tt/GArMu7 http://ift.tt/1tY3uA9">

<!-- 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 6:59:28 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 6:59:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version: Apache Tomcat/8.0.17
Mar 29, 2015 6:59:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built: Jan 9 2015 15:58:59 UTC
Mar 29, 2015 6:59:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number: 8.0.17.0
Mar 29, 2015 6:59:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name: Mac OS X
Mar 29, 2015 6:59:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version: 10.10.2
Mar 29, 2015 6:59:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture: x86_64
Mar 29, 2015 6:59:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JAVA_HOME: /Library/Java/JavaVirtualMachines/jdk1.8.0_31.jdk/Contents/Home/jre
Mar 29, 2015 6:59:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version: 1.8.0_31-b13
Mar 29, 2015 6:59:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor: Oracle Corporation
Mar 29, 2015 6:59:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE: /apache-tomcat-8.0.17
Mar 29, 2015 6:59:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME: /apache-tomcat-8.0.17
Mar 29, 2015 6:59:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=/apache-tomcat-8.0.17
Mar 29, 2015 6:59:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=/apache-tomcat-8.0.17
Mar 29, 2015 6:59:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=/apache-tomcat-8.0.17/webapps
Mar 29, 2015 6:59:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=/apache-tomcat-8.0.17/endorsed
Mar 29, 2015 6:59:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=UTF-8
Mar 29, 2015 6:59:28 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 6:59:29 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
Mar 29, 2015 6:59:29 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Mar 29, 2015 6:59:29 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-nio-8009"]
Mar 29, 2015 6:59:29 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Mar 29, 2015 6:59:29 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1259 ms
Mar 29, 2015 6:59:29 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Mar 29, 2015 6:59:29 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.0.17
Mar 29, 2015 6:59:31 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Mar 29, 2015 6:59:31 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Mar 29, 2015 6:59:31 PM org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization started
Mar 29, 2015 6:59:31 PM org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh
INFO: Refreshing Root WebApplicationContext: startup date [Sun Mar 29 18:59:31 CEST 2015]; root of context hierarchy
Mar 29, 2015 6:59:31 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 6:59:31 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 6:59:32 PM org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization completed in 780 ms
Mar 29, 2015 6:59:32 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'offers'
Mar 29, 2015 6:59:32 PM org.springframework.web.servlet.DispatcherServlet initServletBean
INFO: FrameworkServlet 'offers': initialization started
Mar 29, 2015 6:59:32 PM org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh
INFO: Refreshing WebApplicationContext for namespace 'offers-servlet': startup date [Sun Mar 29 18:59:32 CEST 2015]; parent: Root WebApplicationContext
Mar 29, 2015 6:59:32 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 6:59:32 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 6:59:32 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 6:59:32 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter initControllerAdviceCache
INFO: Looking for @ControllerAdvice: WebApplicationContext for namespace 'offers-servlet': startup date [Sun Mar 29 18:59:32 CEST 2015]; parent: Root WebApplicationContext
Mar 29, 2015 6:59:33 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter initControllerAdviceCache
INFO: Looking for @ControllerAdvice: WebApplicationContext for namespace 'offers-servlet': startup date [Sun Mar 29 18:59:32 CEST 2015]; parent: Root WebApplicationContext
Mar 29, 2015 6:59:33 PM org.springframework.web.servlet.DispatcherServlet initServletBean
INFO: FrameworkServlet 'offers': initialization completed in 1070 ms
Mar 29, 2015 6:59:33 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /apache-tomcat-8.0.17/webapps/docs
Mar 29, 2015 6:59:33 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 6:59:33 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /apache-tomcat-8.0.17/webapps/docs has finished in 131 ms
Mar 29, 2015 6:59:33 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /apache-tomcat-8.0.17/webapps/examples
Mar 29, 2015 6:59:33 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Mar 29, 2015 6:59:33 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Mar 29, 2015 6:59:33 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /apache-tomcat-8.0.17/webapps/examples has finished in 336 ms
Mar 29, 2015 6:59:33 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /apache-tomcat-8.0.17/webapps/host-manager
Mar 29, 2015 6:59:33 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 6:59:33 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /apache-tomcat-8.0.17/webapps/host-manager has finished in 88 ms
Mar 29, 2015 6:59:33 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /apache-tomcat-8.0.17/webapps/manager
Mar 29, 2015 6:59:33 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 6:59:33 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /apache-tomcat-8.0.17/webapps/manager has finished in 102 ms
Mar 29, 2015 6:59:33 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /apache-tomcat-8.0.17/webapps/ROOT
Mar 29, 2015 6:59:33 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 6:59:33 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /apache-tomcat-8.0.17/webapps/ROOT has finished in 103 ms
Mar 29, 2015 6:59:33 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
Mar 29, 2015 6:59:33 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-nio-8009"]
Mar 29, 2015 6:59:33 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 4600 ms
Mar 29, 2015 6:59:34 PM org.springframework.web.servlet.PageNotFound noHandlerFound
WARNING: No mapping found for HTTP request with URI [/SpringMVCTest/] in DispatcherServlet with name 'offers'

Aucun commentaire:

Enregistrer un commentaire