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

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

    评论

报告相同问题?

悬赏问题

  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝