I am trying to develop a new Spring boot application using MVC as a first step to move my existing Spring MVC application to Spring boot.
However, I am facing an is
I have gone exactly the same path. Upgrading a jsp, xml-based spring application to spring boot 2. There are few things you need to consider when migrating:
First remove @EnableWebMvc.
Second you need @ComponentScan on top of MyFirstAppApplication class.
Try to read this article, it helped me alot https://htr3n.github.io/2018/12/jsp-spring-boot/
Third you also need this dependeny together with embed-jasper:
org.apache.tomcat.embed
tomcat-embed-core
9.0.22
Last but not least this is a shortcut for creating a view handler in java
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix:.jsp
and as far as I know it only works in spring boot 2. You can have Java implementation instead and debug it to see if it ever hit that.
@Override
public void configureViewResolvers(ViewResolverRegistry registry) {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix("/WEB-INF/jsp/");
resolver.setSuffix(".jsp");
registry.viewResolver(resolver);
}
Because in my case for example I didn't even need a specific or default resolver. I had different resolver for each Controller that I had to define in xml/bean and inject in each class.