springBoot配置视图解析 跳转jsp页面遇见错误之一

   注意spring boot 版本,版本低的要加.mvc

配置与代码:

application.properties

server.port=8000
#spring mvc 
spring.mvc.view.prefix=/WEB-INF/
spring.mvc.view.suffix=.jsp

pom.xml


  4.0.0
 
    org.springframework.boot
    spring-boot-starter-parent 
    1.2.7.RELEASE
 

  cn.springboot
  SpringBoot
  1-SNAPSHOT
  war
  SpringBoot
 
   
        org.springframework.boot
        spring-boot-starter-web
   

   
   
   org.apache.tomcat.embed
   tomcat-embed-jasper
   

 
 
   javax.servlet  
   javax.servlet-api  
   
 
 
 
   javax.servlet  
   jstl  


   




org.springframework.boot
spring-boot-maven-plugin


            maven-compiler-plugin
           
                   1.7
                   1.7
           

       





测试controller

@Controller
public class TestController {


@RequestMapping(value = "/index")
public String index() {
System.err.println(1111);
return "index";
}


@RequestMapping("/")
@ResponseBody
public String test() {
return "welcome spring boot";
}
}

启动类

@SpringBootApplication
public class SampleController extends SpringBootServletInitializer {


/*
* @Override protected SpringApplicationBuilder
* configure(SpringApplicationBuilder application) { return
* application.sources(SampleController.class); }
*/


public static void main(String[] args) throws Exception {
SpringApplication.run(SampleController.class, args);
}
}


然后就报错了,错误如下:

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Tue Mar 28 16:37:25 CST 2017
There was an unexpected error (type=Internal Server Error, status=500).
Circular view path [index]: would dispatch back to the current handler URL [/index] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)

!!!!!!

视图不对 啊

解决办法:原来上面的application.properties配置文件有问题

去掉MVC改成

server.port=8000
#spring mvc 
spring.view.prefix=/WEB-INF/
spring.view.suffix=.jsp


运行成功


你可能感兴趣的:(springBoot配置视图解析 跳转jsp页面遇见错误之一)