Quando coloco no meu controller @RequestMapping("/") não funciona, porém se eu coloco @RequestMapping("/home") e faço o acesso funciona normalmente.
HomeController
@Controller
public class HomeController {
@RequestMapping("/")
public String home() {
System.out.println("Exibindo a home da CDC");
return "home";
}
}
ServletSpringMvc
public class ServletSpringMvc extends AbstractAnnotationConfigDispatcherServletInitializer{
@Override
protected Class<?>[] getRootConfigClasses() {
// TODO Auto-generated method stub
return null;
}
@Override
protected Class<?>[] getServletConfigClasses() {
return new Class[] {AppWebConfiguration.class};
}
@Override
protected String[] getServletMappings() {
return new String[] {"/"};
}
}
AppWebConfiguration
@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;
}
}