java - Spring框架的循环 View 路径异常

标签 java eclipse maven spring-mvc spring-boot

基本上,访问“/”和“/a”是在浏览器上工作的。访问“/testme”不工作。错误是

2016-03-13 15:04:37.709 ERROR 1933 --- [io-8080-exec-57] o.s.boot.context.web.ErrorPageFilter : Forwarding to error page from request [/testmenull] due to exception [Circular view path [testme.html]: would dispatch back to the current handler URL [/XXXX/testme.html] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)]

我执行字符串 grep,但找不到“ViewResolver”。我不知道为什么“/”和“/a”起作用。有什么想法吗?

更多请看图: enter image description here

所有 xml 文件: enter image description here

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.xxxxx</groupId>
  <artifactId>Monitor</artifactId>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>
  <!--<name>Monitor</name>-->
  <url>http://maven.apache.org</url>

  <parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>1.1.9.RELEASE</version>
  </parent>

  <dependencies>
      <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-web</artifactId>
      </dependency>
      <dependency>
          <groupId>javax.websocket</groupId>
          <artifactId>javax.websocket-api</artifactId>
          <version>1.1</version>
          <scope>provided</scope> <!--for web socket-->
      </dependency>
      <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-data-jpa</artifactId>
      </dependency>
      <dependency>
          <groupId>mysql</groupId>
          <artifactId>mysql-connector-java</artifactId>
          <version>5.1.31</version>
      </dependency>
      <dependency>
          <groupId>org.springframework.hateoas</groupId>
          <artifactId>spring-hateoas</artifactId>
      </dependency>
      <dependency>
          <groupId>com.google.code.gson</groupId>
          <artifactId>gson</artifactId>
          <version>2.3</version>
      </dependency>
      <dependency>
          <groupId>com.fasterxml.jackson.core</groupId>
          <artifactId>jackson-databind</artifactId>
      </dependency>
      <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
      </dependency>
  </dependencies>

  <build>
      <finalName>Monitor</finalName>
      <plugins>
          <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-compiler-plugin</artifactId>
              <version>3.1</version>
              <configuration>
                  <compilerVersion>1.7</compilerVersion>
                  <source>1.7</source>
                  <target>1.7</target>
              </configuration>
          </plugin>
          <plugin>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-maven-plugin</artifactId>
          </plugin>
          <!--<plugin>-->
              <!--<groupId>org.apache.maven.plugins</groupId>-->
              <!--<artifactId>maven-source-plugin</artifactId>-->
              <!--<executions>-->
                  <!--<execution>-->
                      <!--<id>attach-sources</id>-->
                      <!--<goals>-->
                          <!--<goal>jar</goal>-->
                      <!--</goals>-->
                  <!--</execution>-->
              <!--</executions>-->
          <!--</plugin>-->
      </plugins>
      <resources>
          <resource>
              <directory>${basedir}/src/main/resources</directory>
          </resource>
          <resource>
              <directory>${basedir}/src/main/java</directory>
          </resource>
      </resources>
  </build>
</project>

网络.xml

<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
  <display-name>Archetype Created Web Application</display-name>
</web-app>

最佳答案

@RequestMapping的值是“testme”,return的值也是“testme”,这样当你访问“/testme”时,web又会重定向到“/testme”。这将导致无休止地重定向到“/testme”。

关于java - Spring框架的循环 View 路径异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35966441/

相关文章:

java - 如何在 Java 中执行 Selenium 测试

maven WAR 插件跳过资源?

java - Android扫描apk中的包中的文件

java - 通过 MobileFirst Adapter 下载 PDF 文件

java - Facebook 营销 API 使用 API 自定义网站受众定位

eclipse - 在 git 中添加到索引是什么意思?

java - MP3 的音频格式帧大小?

java - 您在哪里配置 Eclipse Java 编译器 (javac) 标志?

java - 将子项目中的所有依赖项 jar 复制到父项目目录中

java - 使用 tomcat7-maven-plugin 设置已部署 war 的名称