Basically, access "/" and "/a" are working on browser. Acess "/testme" is not working. Error is
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.)]
I do a string grep, but cannot found "ViewResolver". I have no idea why "/" and "/a" work. Any idea?
See image for more:
All xml files:
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>
web.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>
the value of @RequestMapping
is "testme" and the value of return is also "testme" so that when you access "/testme", the web will redirect to "/testme" again. This will lead to endless redirection to "/testme".
Tried all the above suggestions and it didn't work for me. But the issue was resolved when I changed the annotation on my controller class from @Controller
to @RestController
(which is a combination of @Controller
and @ResponseBody
).
If you are using gradle you have to add:
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
, or maven find this dependency.
If you are not returning a view. But only a JSON, adding @ResponseBody
to the response helps returning a JSON value rather than a view.
Eg:
@RequestMapping(value="/getList",method = RequestMethod.GET)
public @ResponseBody List<LOne> getLOne(){
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With