Roc_strong 2016-04-27 07:33 采纳率: 0%
浏览 16522
已结题

spring boot中找不到jsp

查了一天了也没查到问题,我配置了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好像没有设置

  • 写回答

5条回答

  • 业余选手 2016-04-27 09:29
    关注

    配置文件没配对吧
    <?xml version="1.0" encoding="UTF-8"?>
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
    http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd">

    <!-- scan the package and the sub package -->
    <context:component-scan base-package="test.SpringMVC"/>
    
    <!-- don't handle the static resource -->
    <mvc:default-servlet-handler />
    
    <!-- if you use annotation you must configure following setting -->
    <mvc:annotation-driven />
    
    <!-- configure the InternalResourceViewResolver -->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"
            id="internalResourceViewResolver">
        <!-- 前缀 -->
        <property name="prefix" value="/WEB-INF/jsp/" />
        <!-- 后缀 -->
        <property name="suffix" value=".jsp" />
    </bean>
    

    http://www.admin10000.com/document/6436.html

    评论

报告相同问题?

悬赏问题

  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况
  • ¥15 画两个图 python或R