这是我的Spring Inialization的DispatcherServletInitializer类
public class MyDispatcherServletInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override
protected Class<?>[] getRootConfigClasses() {
return null;
}
@Override
protected Class<?>[] getServletConfigClasses() {
return new Class[] {AppConfig.class};
}
@Override
protected String[] getServletMappings() {
return new String[] {"/*"};
}
}
这是我的WelcomeController类
@Controller
public class WelcomeController {
@RequestMapping("/")
public ModelAndView hello(HttpServletRequest req, HttpServletResponse resp) {
return new ModelAndView("hello-world");
}
}
这是我的AppConfig类
@EnableWebMvc
@Configuration
@ComponentScan("demo.spring.controllers")
public class AppConfig {
@Bean
public ViewResolver getViewResolver() {
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setPrefix("/WEB-INF/views/jsp/");
viewResolver.setSuffix(".jsp");
return viewResolver;
}
}
请为我提供正确的解决方案以使其正常运行...