Solucionado (ver solução)
Solucionado
(ver solução)
3
respostas

ERRO 404

FIZ TODOS OS PASSO DO ULTIMO VIDEO DO CURSO COMEÇANDO COM SPRINGMVC, MAS ESTÁ DANDO O SEGUINTE ERRO:

HTTP Status 404 - /casadocodigo/

type Status report

message /casadocodigo/

description The requested resource is not available.

Apache Tomcat/7.0.73

COMO RESOLVER? OBG

3 respostas
solução!

Boa noite João, pode colar seu código do controller e onde você seta o prefixo e sufixos para as JSP por favor?

package br.com.casadocodigo.loja.cotroller;

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

@Controller public class HomeController {

@RequestMapping("/") public String index(){ System.out.println("Entrando na home da CDC"); return "home";

}

}

package br.com.casadocodigo.loja.conf;

import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.view.InternalResourceViewResolver;

import br.com.casadocodigo.loja.cotroller.HomeController;

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

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

}

package br.com.casadocodigo.loja.conf;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.view.InternalResourceViewResolver;

import br.com.casadocodigo.loja.cotroller.HomeController;

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

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

}
package br.com.casadocodigo.loja.cotroller;

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

@Controller
public class HomeController {

    @RequestMapping("/")
    public String index(){
        System.out.println("Entrando na home da CDC");
        return "home";

    }

}