title: Spring Boot JSP 404.Whitelabel Error Page
body: <p>Can't load a very simple JSP page with spring-boot, getting 404 Not Found</p>
  
  <p>HmisApplication.class</p>
  
  <pre><code>@SpringBootApplication
  public class HmisApplication extends SpringBootServletInitializer {
  @Override
  protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
      return application.sources(HmisApplication.class);
  }
  
  public static void main(String[] args) throws Exception {
      SpringApplication.run(HmisApplication.class, args);
  }
  }
  </code></pre>
  
  <p>MainController.java</p>
  
  <pre><code>@Controller
  public class WelcomeController {
  @RequestMapping("/")
  public String home(Map&lt;String, Object&gt; model) {
      model.put("message", "HowToDoInJava Reader !!");
      return "index";
  }
  
  @RequestMapping("/next")
  public String next(Map&lt;String, Object&gt; model) {
      model.put("message", "You are in new page !!");
      return "next";
  }
  }
  </code></pre>
  
  <p>application.properties</p>
  
  <pre><code>spring.profiles.active=dev,build-info
  
  server.contextPath=/hmis
  server.port=7070
  spring.metrics.export.enabled=true
  
  spring.main.banner-mode=off
  
  spring.mvc.view.prefix: /WEB-INF/jsp/
  spring.mvc.view.suffix: .jsp
  application.message: Hello Phil
  
  # HTTP encoding (HttpEncodingProperties)
  spring.http.encoding.force-request=true
  spring.http.encoding.charset=UTF-8
  spring.http.encoding.enabled=true
  spring.http.encoding.force=true
  </code></pre>
  
  <p>pom.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  </code></pre>
  
  <p>http://maven.apache.org/xsd/maven-4.0.0.xsd">
      4.0.0</p>
  
  <pre><code>&lt;groupId&gt;com.hmis&lt;/groupId&gt;
  &lt;artifactId&gt;hmis&lt;/artifactId&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;packaging&gt;war&lt;/packaging&gt;
  
  &lt;name&gt;hmis&lt;/name&gt;
  &lt;description&gt;Demo project for Spring Boot&lt;/description&gt;
  
  &lt;parent&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
      &lt;version&gt;1.5.3.RELEASE&lt;/version&gt;
      &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
  &lt;/parent&gt;
  
  &lt;properties&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;project.reporting.outputEncoding&gt;UTF-8&lt;/project.reporting.outputEncoding&gt;
      &lt;java.version&gt;1.8&lt;/java.version&gt;
  &lt;/properties&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.activiti&lt;/groupId&gt;
          &lt;artifactId&gt;activiti-spring-boot-starter-basic&lt;/artifactId&gt;
          &lt;version&gt;5.21.0&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;!--
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-security&lt;/artifactId&gt;
      &lt;/dependency&gt;
      --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;mysql&lt;/groupId&gt;
          &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
          &lt;scope&gt;runtime&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;!-- Tomcat Embed --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt;
          &lt;!--&lt;scope&gt;provided&lt;/scope&gt;--&gt;
      &lt;/dependency&gt;
      &lt;!-- JSTL --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;jstl&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;!-- To compile JSP files --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.tomcat.embed&lt;/groupId&gt;
          &lt;artifactId&gt;tomcat-embed-jasper&lt;/artifactId&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  
  &lt;/dependencies&gt;
  
  &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
              &lt;configuration&gt;
                  &lt;useSystemClassLoader&gt;false&lt;/useSystemClassLoader&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p>
  MvcConfiguration.java</p>
  
  <pre><code>@Configuration
  @EnableWebMvc
  @ComponentScan
  public class MvcConfiguration extends WebMvcConfigurerAdapter
  {
  @Override
  public void configureViewResolvers(ViewResolverRegistry registry) {
      InternalResourceViewResolver resolver = new InternalResourceViewResolver();
      resolver.setPrefix("/WEB-INF/jsp/");
      resolver.setSuffix(".jsp");
      resolver.setViewClass(JstlView.class);
      registry.viewResolver(resolver);
  }
  }
  </code></pre>
  
  <p>File Structure</p>
  
  <pre><code>        ├── src
          ├── main
          │   ├── java
          │   │   └── com
          │   │       └── hmis
          │   │             ├── HmisApplication.java
          │   │             ├── MvcConfiguration.java
          │   │             ├── WelcomeController.java  
          │   └── resources
          │       └── application.properties
          │       └── webapp
          │             └── WEB-INF
          │                   └── jsp
          │                         └── index.jsp
          │                         └── next.jsp
  </code></pre>