DispatcherServlet and web.xml in Spring Boot

后端 未结 4 1808
死守一世寂寞
死守一世寂寞 2020-12-13 04:43

I\'m currently trying to move my project from Java EE to Spring Boot project. However, i\'ve been stucked and confused on the part with dispatcher servlet and web.xml and it

4条回答
  •  不知归路
    2020-12-13 05:17

    Spent quite some time so sharing three things I remember to make it working from command line.

    1. Most important: JSPs should be kept only in folder /src/main/resources/META-INF/resources. more info here
    2. Make sure that maven while building jar is considering your folders /src/main/resources, otherwise add these lines in your pom.xml

      
         
            src/main/resources   
          
        

    1. In your mvc config file

      @Configuration
      public class MvcConfig extends WebMvcConfigurerAdapter {
          @Bean
          public InternalResourceViewResolver viewResolver(){
          InternalResourceViewResolver resolver = new InternalResourceViewResolver();
          resolver.setPrefix("/Representation/");
          resolver.setSuffix(".jsp");
          return resolver;
      }
      

提交回复
热议问题