1
resposta

The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.

Pessoal já limpei meu projeto, já criei de novo, já desativei e ativei o build automático do eclipse e continuo com o mesmo erro quando tento executar uma pagina que traz uma lista.

No meu console não traz nenhum erro somente no navegador

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

@Controller
public class HomeController {

    @RequestMapping("/")
    public String index() {
        System.out.println("Exibindo a home da CDC");
        return "home";
    }
}
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

public class ServletSpringMVC extends AbstractAnnotationConfigDispatcherServletInitializer{

    @Override
    protected Class<?>[] getRootConfigClasses() {
        return null;
    }

    @Override
    protected Class<?>[] getServletConfigClasses() {
        return new Class[] { AppWebConfiguration.class};
    }

    @Override
    protected String[] getServletMappings() {
        return new String[] {"/"};
    }

}
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.view.InternalResourceViewResolver;

public class AppWebConfiguration {

    @Bean
    public InternalResourceViewResolver internalResourceViewResolver() {
        InternalResourceViewResolver resolver = new InternalResourceViewResolver();
        resolver.setPrefix("/WEB-INF/views/");
        resolver.setSuffix(".jsp");
        return resolver;
    }

}
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Livros de Java, Android, iPhone, PHP, Ruby e muito mais - Casa do Código</title>
</head>
<body>

    <h1>Casa do Código</h1>
    <table>
        <tr>
            <td>Java 8 Prático</td>
            <td>Certificação OCJP</td>
        </tr>
        <tr>
            <td>TDD na Prática - Java</td>
            <td>Google Android</td>
        </tr>
    </table>
</body>
</html>
1 resposta

Olá Rogério, tudo bem com você?

Conseguiu resolver seu problema? Espero que sim!

Mas caso não, acredito que seu projeto estava dando erro por conta que você esqueceu de colocar as 2 anotações em nosso AppWebConfiguration:

@EnableWebMvc
@ComponentScan(basePackageClasses={HomeController.class})
public class AppWebConfiguration {
}

Provavelmente dessa forma já irá funcionar normalmente, mas caso de algum outro erro pode mandar o erro aqui :)

Abraços e Bons Estudos!

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software