该异常是因为用定义了带@EnableWebMvc注解的配置类后发生的,在带该注解的配置类中加入下面的代码就可以了:
@Bean
public InternalResourceViewResolver viewResolver() {
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setPrefix("/WEB-INF/jsp/");
viewResolver.setSuffix(".jsp");
return viewResolver;
}
有了这段代码在application.yml中的下面的配置就没有必要了
spring:
mvc:
view:
prefix: /WEB-INF/
suffix: .jsp