title: spring boot mvc how to support multiple viewresoler (eg. jsp and freemarker)
body: <p>I hope my web application support jsp and freemarker both templates.i have read the article at below.
  <a href="https://spring.io/blog/2013/06/03/content-negotiation-using-views" rel="nofollow">https://spring.io/blog/2013/06/03/content-negotiation-using-views</a>
  my code as below. the result is only the jsp template OK.
  what wrong with my configration?</p>
  
  <h3>MvcConfiguration.java</h3>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>@Configuration
  @EnableWebMvc
  public class MvcConfiguration extends WebMvcConfigurerAdapter {
  
   @Bean
   public InternalResourceViewResolver getJspViewResolver() {
    InternalResourceViewResolver resolver = new InternalResourceViewResolver();
    resolver.setPrefix("/WEB-INF/jsp/");
    resolver.setSuffix(".jsp");
    resolver.setOrder(0);
    return resolver;
   }
  
   @Bean
   public FreeMarkerViewResolver getFmViewResolver() {
    FreeMarkerViewResolver resolver = new FreeMarkerViewResolver();
    resolver.setCache(true);
    resolver.setPrefix("");
    resolver.setSuffix(".ftl");
    resolver.setContentType("text/html; charset=UTF-8");
    resolver.setOrder(1);
    return resolver;
   }
   
   @Bean
     public FreeMarkerConfigurer freemarkerConfig() throws IOException, TemplateException {
       FreeMarkerConfigurationFactory factory = new FreeMarkerConfigurationFactory();
       factory.setTemplateLoaderPath("classpath:templates");
       factory.setDefaultEncoding("UTF-8");
       FreeMarkerConfigurer result = new FreeMarkerConfigurer();
       result.setConfiguration(factory.createConfiguration());
       return result;
     } 
   
  
   @Bean
   public ViewResolver contentNegotiatingViewResolver(
     ContentNegotiationManager manager) {
    List&lt;ViewResolver&gt; resolvers = new ArrayList&lt;ViewResolver&gt;();
    resolvers.add(getJspViewResolver());
    resolvers.add(getFmViewResolver());
  
    ContentNegotiatingViewResolver resolver = new ContentNegotiatingViewResolver();
    resolver.setViewResolvers(resolvers);
    resolver.setContentNegotiationManager(manager);
    return resolver;
   }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <h3>TestController.java</h3>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>@Controller
  public class TestController {
  
   @RequestMapping("/hello")
   public String jspView() {
    return "hello";
   }
   
   @RequestMapping("/fm")
   public String freemarkerView() {
    return "fm";
   }
   
  }</code></pre>
  </div>
  </div>
  </p>
  
  <h3>hello.jsp</h3>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;%@ page language="java" contentType="text/html; charset=utf-8"
      pageEncoding="utf-8"%&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;
  &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;%
   out.println("hello jsp");
  %&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <h3>fm.ftl</h3>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  
  &lt;html lang="en"&gt;
  
  &lt;body&gt;
    hello freemarker
  &lt;/body&gt;
  
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>