查了一天了也没查到问题,我配置了mvc的前缀和后缀,可就是返回不了jsp,是打的war包有问题吗,
还是缺少什么web的包,它只会报Circular view path [/main]: would dispatch back to the current handler URL [/main] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.),实在是查不到怎么解决了,照着springboot的官方web例子改也不行,直接返回了字符串而不是jsp页面,真心求各位帮帮忙。
yml配置文件里的源码
mvc:
view:
prefix: /WEB-INF/jsp/
suffix: .jsp
gradle的依赖包引入
compile 'org.springframework.boot:spring-boot-starter-data-jpa'
compile 'org.springframework.boot:spring-boot-starter-freemarker'
compile 'org.springframework.boot:spring-boot-starter-groovy-templates'
compile 'org.springframework.boot:spring-boot-starter-jdbc'
compile 'com.h2database:h2:1.4.190'
compile 'com.alibaba:fastjson:1.2.7'
compile 'com.google.guava:guava:18.0'
compile 'org.springframework.boot:spring-boot-starter-redis'
compile 'org.springframework.boot:spring-boot-starter-web'
// compile 'org.springframework.boot:spring-boot-starter-jetty'
compile 'org.springframework.boot:spring-boot-starter-tomcat'
compile 'org.apache.tomcat.embed:tomcat-embed-jasper'
compile 'javax.servlet:jstl'
compile 'org.apache.directory.studio:org.apache.commons.lang:2.6'
compile 'commons-io:commons-io:2.4'
compile 'mysql:mysql-connector-java'
testCompile 'org.springframework.boot:spring-boot-starter-test'
compile 'org.springframework.boot:spring-boot-starter-data-rest'
compile 'org.springframework.boot:spring-boot-configuration-processor'
compile 'com.googlecode.xmemcached:xmemcached:2.0.0'
controller
@RequestMapping("/main")
public ModelAndView welcome1() {
logger.error("111111111111111")
return new ModelAndView("/main")
}
日志能打出来,但是这个main.jsp找不到
war包的目录结构
又去查了一下,视频和例子都在说引入
compile 'org.springframework.boot:spring-boot-starter-tomcat'
compile 'org.apache.tomcat.embed:tomcat-embed-jasper'
两个依赖后,注释为@Controller,直接return字符串类型的jsp名就可以
可就是还是不行,ViewResolver好像没有设置