Java - Error 404,AYUDA POR FAVOR (SPRING)

 
Vista:
sin imagen de perfil

Error 404,AYUDA POR FAVOR (SPRING)

Publicado por Juan Francisco (58 intervenciones) el 22/06/2017 17:27:29
Buenas soy nuevo en esto pero me veo desesperado frente a este error,estoy iniciandome en spring ,quería hacer algo básico,pero me encontre con este problema
tengo una pagina redirect.jsp que tiene un enlace a ir.html, para que el dispatcher junto con el controlador lo redirecione a la vista creada ..pero cuando pincho el
enlace sale esto,y error 404
Esta es mi url despues de pinchar http://localhost:8081/WebSpringDos/ir.html
y abajo lo que sale en la consola
jun 16, 2017 8:44:54 PM org.springframework.web.servlet.PageNotFound noHandlerFound
ADVERTENCIA: No mapping found for HTTP request with URI [/WebSpringDos/ir.html] in DispatcherServlet with name 'spring'


mi archivo spring-servlet.xml

<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:p="http://www.springframework.org/schema/p"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">

<context:component-scan base-package="com.juan.controladores"/>
<context:annotation-config/>
<mvc:annotation-driven/>
<!--<mvc:default-servlet-handler/> -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/WEB-INF/jsp"/>
<property name="suffix" value=".jsp"/>
</bean>
</beans>

mi archivo 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>WebSpringDos</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/aplication-context.xml</param-value>
</context-param>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<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>
<welcome-file-list>
<welcome-file>redirect.jsp</welcome-file>
</welcome-file-list>
</web-app>


mi controlador ProductoControlador:

package com.juan.controladores;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.servlet.ModelAndView;



@Controller
public class ProductoControlador {
@RequestMapping("ir")
public ModelAndView ir(){
ModelAndView mv=new ModelAndView();
System.out.println("Soy una vista");
mv.setViewName("index");
return mv;
}
}


Mi pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>WebSpringDos</groupId>
<artifactId>WebSpringDos</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.2.18.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.2.18.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>3.2.18.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.2.18.RELEASE</version>
</dependency>
</dependencies>

<build>
<testSourceDirectory>src/main/test</testSourceDirectory>
<resources>
<resource>
<directory>src/main/webapp</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
</project>

Y creo que con esa información sobra,estoy utilizando Eclipse y Tomcat 7..no se si me podeis ayudar ..soy nuevo en este framework ,y
estoy muy interesado en aprender como se utiliza pero no tengo ayuda nada mas de google, pero esta vez no se por que falla..

Amm por si os sirve de ayuda no da ningun error en el despliegue a tomcat

jun 16, 2017 8:44:29 PM org.apache.catalina.core.AprLifecycleListener init
INFORMACIÓN: Cargada la biblioteca nativa APR de Apache Tomcat 1.1.29 con la versión APR 1.4.8.
jun 16, 2017 8:44:30 PM org.apache.catalina.core.AprLifecycleListener init
INFORMACIÓN: Capacidades APR: IPv6 [true], enviar fichero [true], aceptar filtros [false], aleatorio [true].
jun 16, 2017 8:44:31 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
ADVERTENCIA: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:WebSpringDos' did not find a matching property.
jun 16, 2017 8:44:32 PM org.apache.catalina.core.AprLifecycleListener initializeSSL
INFORMACIÓN: OpenSSL inicializado correctamente (OpenSSL 1.0.1e 11 Feb 2013)
jun 16, 2017 8:44:33 PM org.apache.coyote.AbstractProtocol init
INFORMACIÓN: Initializing ProtocolHandler ["http-apr-8081"]
jun 16, 2017 8:44:33 PM org.apache.coyote.AbstractProtocol init
INFORMACIÓN: Initializing ProtocolHandler ["ajp-apr-8010"]
jun 16, 2017 8:44:33 PM org.apache.catalina.startup.Catalina load
INFORMACIÓN: Initialization processed in 6049 ms
jun 16, 2017 8:44:33 PM org.apache.catalina.core.StandardService startInternal
INFORMACIÓN: Arrancando servicio Catalina
jun 16, 2017 8:44:33 PM org.apache.catalina.core.StandardEngine startInternal
INFORMACIÓN: Starting Servlet Engine: Apache Tomcat/7.0.47
jun 16, 2017 8:44:41 PM org.apache.catalina.util.SessionIdGenerator createSecureRandom
INFORMACIÓN: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [5.531] milliseconds.
jun 16, 2017 8:44:47 PM org.apache.catalina.core.ApplicationContext log
INFORMACIÓN: No Spring WebApplicationInitializer types detected on classpath
jun 16, 2017 8:44:47 PM org.apache.catalina.core.ApplicationContext log
INFORMACIÓN: Initializing Spring root WebApplicationContext
jun 16, 2017 8:44:47 PM org.springframework.web.context.ContextLoader initWebApplicationContext
INFORMACIÓN: Root WebApplicationContext: initialization started
jun 16, 2017 8:44:47 PM org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh
INFORMACIÓN: Refreshing Root WebApplicationContext: startup date [Fri Jun 16 20:44:47 CEST 2017]; root of context hierarchy
jun 16, 2017 8:44:47 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFORMACIÓN: Loading XML bean definitions from ServletContext resource [/WEB-INF/aplication-context.xml]
jun 16, 2017 8:44:48 PM org.springframework.beans.factory.config.PropertyPlaceholderConfigurer loadProperties
INFORMACIÓN: Loading properties file from ServletContext resource [/WEB-INF/jdbc.properties]
jun 16, 2017 8:44:48 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFORMACIÓN: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@8e2f37: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,propertyConfigurer,dataSource,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor]; root of factory hierarchy
jun 16, 2017 8:44:48 PM org.springframework.jdbc.datasource.DriverManagerDataSource setDriverClassName
INFORMACIÓN: Loaded JDBC driver: com.mysql.jdbc.Driver
jun 16, 2017 8:44:48 PM org.springframework.web.context.ContextLoader initWebApplicationContext
INFORMACIÓN: Root WebApplicationContext: initialization completed in 1453 ms
jun 16, 2017 8:44:48 PM org.apache.catalina.core.ApplicationContext log
INFORMACIÓN: Initializing Spring FrameworkServlet 'spring'
jun 16, 2017 8:44:48 PM org.springframework.web.servlet.DispatcherServlet initServletBean
INFORMACIÓN: FrameworkServlet 'spring': initialization started
jun 16, 2017 8:44:48 PM org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh
INFORMACIÓN: Refreshing WebApplicationContext for namespace 'spring-servlet': startup date [Fri Jun 16 20:44:48 CEST 2017]; parent: Root WebApplicationContext
jun 16, 2017 8:44:48 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFORMACIÓN: Loading XML bean definitions from ServletContext resource [/WEB-INF/spring-servlet.xml]
jun 16, 2017 8:44:49 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFORMACIÓN: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1eebffa: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,mvcContentNegotiationManager,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0,org.springframework.format.support.FormattingConversionServiceFactoryBean#0,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#0,org.springframework.web.servlet.handler.MappedInterceptor#0,org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver#0,org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver#0,org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver#0,org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping,org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter,org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter,viewResolver,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@8e2f37
jun 16, 2017 8:44:50 PM org.springframework.web.servlet.DispatcherServlet initServletBean
INFORMACIÓN: FrameworkServlet 'spring': initialization completed in 1219 ms
jun 16, 2017 8:44:50 PM org.apache.coyote.AbstractProtocol start
INFORMACIÓN: Starting ProtocolHandler ["http-apr-8081"]
jun 16, 2017 8:44:50 PM org.apache.coyote.AbstractProtocol start
INFORMACIÓN: Starting ProtocolHandler ["ajp-apr-8010"]
jun 16, 2017 8:44:50 PM org.apache.catalina.startup.Catalina start
INFORMACIÓN: Server startup in 16721 ms
Hasta que pincho el enlace y boom
jun 16, 2017 8:44:54 PM org.springframework.web.servlet.PageNotFound noHandlerFound
ADVERTENCIA: No mapping found for HTTP request with URI [/WebSpringDos/ir.html] in DispatcherServlet with name 'spring'


Y ERROR 404 ..ya no se que hacer ..
Esta es la estructura de mi proyecto
estructura
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder