1、config包
1.1、创建SpringMvcConfig类并实现接口WebMvcConfigurer
java">@EnableWebMvc
public class SpringMvcConfig implements WebMvcConfigurer {//视图解析器@Beanpublic ViewResolver viewResolver() {InternalResourceViewResolver viewResolver =new InternalResourceViewResolver();viewResolver.setPrefix("/WEB-INF/views/");viewResolver.setSuffix(".jsp");return viewResolver;}//配置WebMvc相关配置,实现接口 WebMvcConfigurer//视图控制,默认首页@Overridepublic void addViewControllers(ViewControllerRegistry registry) {registry.addViewController("/").setViewName("index");}}
1.2、AppConfig类
java">@Configuration
@ComponentScan("")
@Import({SpringMvcConfig.class})
public class AppConfig {}