Ola galera, sou iniciante no Spring-MVC e estou com problemas no mapeamento da página, só recebo a mensagem abaixo:
The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
Gostaria que me ajudassem por favor.
Spring-Context:
> <?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.2.xsd
> http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
> http://www.springframework.org/schema/context
> http://www.springframework.org/schema/context/spring-context-4.2.xsd"
> >
>
> <context:component-scan base-package="org.casadocodigo.controller"/><!--Especifica pro netbeans onde estão as classe-->
>
> <mvc:annotation-driven/>
> <!--Especificar onde estão as paginas-->
> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
> <property name="prefix" value="/WEB-INF/views/"/>
> <property name="sufix" value=".jsp"/>
> </bean>
> </beans>
web.xml
> <?xml version="1.0" encoding="UTF-8"?>
> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
> version="4.0">
> <!-- Servlet que irá processar as requisiçoes -->
> <servlet>
> <servlet-name>dispatcherServlet</servlet-name>
> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
> <init-param>
> <param-name>contextConfigLocation</param-name>
> <param-value>/WEB-INF/dispatcherServlet/spring-context.xml</param-value>
> </init-param>
> <load-on-startup>1</load-on-startup>
> </servlet>
>
> <servlet-mapping>
> <servlet-name>dispatcherServlet</servlet-name>
> <url-pattern>/</url-pattern>
> </servlet-mapping>
>
>
> </web-app>
Controller
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.casadocodigo.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
/**
*
* @author alvaro
*/
@Controller
@RequestMapping("/home")
public class HomeController {
@RequestMapping(method = RequestMethod.GET)
public String home(){
System.out.println("Executando logica com spring");
return "home";
}
}
jsp
> <%@page contentType="text/html" pageEncoding="UTF-8"%>
> <!DOCTYPE html>
> <html>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
> <title>JSP Page</title>
> </head>
> <body>
> <h1>Hello World!</h1>
> </body>
> </html>
obs: estou usando o tomcat 8.5.43 e a página inicial dele carrega. A minha IDE é o Apache Netbeans.