title: how to return a web page from a maven project
body: <p>I am trying to return web pages using a maven project. This works for html pages, but I need JSP. When I try to load a JSP page on <a href="http://localhost:8080/home" rel="nofollow noreferrer">http://localhost:8080/home</a> the console says that the initialization of the dispatcherservlet has started an completed, but the webpage is not returned to the browser. </p>
  
  <p>here's the code:</p>
  
  <p>the main class:</p>
  
  <pre><code>package com.example;
  
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.ComponentScan;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.web.servlet.ViewResolver;
  import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
  import org.springframework.web.servlet.config.annotation.EnableWebMvc;
  import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
  import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
  import org.springframework.web.servlet.view.InternalResourceViewResolver;
  
  @SpringBootApplication
  @Configuration
  @ComponentScan(basePackages="com.example")
  @EnableWebMvc
  public class DemoApplication extends WebMvcConfigurerAdapter{
  
      public static void main(String[] args) {
          SpringApplication.run(DemoApplication.class, args);
      }
  
      @Bean
      public ViewResolver getViewResolver(){
          InternalResourceViewResolver resolver = new InternalResourceViewResolver();
          resolver.setPrefix("static/templates/");
          resolver.setSuffix(".jsp");
          return resolver
     }
  
  
  
      @Override
      public void configureDefaultServletHandling(
              DefaultServletHandlerConfigurer configurer) {
          configurer.enable();
      }
  }
  </code></pre>
  
  <p>and my controller class:</p>
  
  <pre><code>package com.example.controller;
  
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  
  @Controller
  public class HomeController {
  
       @RequestMapping(value="/home")
          public String home(){
              return "home";
          }
  
  }
  </code></pre>