Spring Boot项目Circular view path问题解决
使用Spring Boot创建Spring MVC项目,访问url请求出现问题:Circular view path
1、问题描述
控制台打印:
javax.servlet.ServletException: Circular view path [greeting]: would dispatch back to the current handler URL [/greeting] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)

浏览器访问:

2、项目代码
(1)Spring MVC的controller
package com.hello.web; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; @Controller
public class GreetingController {
@RequestMapping("/greeting")
public String greeting(@RequestParam(value="name",required=false,defaultValue="World")String name, Model model) {
model.addAttribute("name", name);
return "greeting";
}
}
(2)页面代码
使用 thymeleaf模板框架,负责服务端渲染html页面
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Spring Boot thymeleaf 应用</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
</head>
<body>
<p th:text="'hello, '+${name}+'!'" />
</body>
</html>
3、解决方法
在 项目的 pom.xml中添加 thymeleaf 的 spring boot starter
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
4、问题解决
再次通过浏览器地址栏,访问: http://localhost:8080/greeting?name=zhangsan

Donate捐赠
如果我的文章帮助了你,可以赞赏我 1 元,让我继续写出更好的内容)

(微信) (支付宝)
微信/支付宝 扫一扫
Spring Boot项目Circular view path问题解决的更多相关文章
- Spring boot项目maven的profile多环境配置不自动替换变量的问题解决
Spring boot项目maven的profile多环境配置不自动替换变量的问题解决 在网上找了好久,配置都很简单,可是我的程序就是不能自动替换变量,最终单独测试,发现原来是引用spring b ...
- 如何在Spring MVC Test中避免”Circular view path” 异常
1. 问题的现象 比如在webConfig中定义了一个viewResolver public class WebConfig extends WebMvcConfigurerAdapter { //配 ...
- 如何在Spring MVC Test中避免”Circular view path” 异常(转)
文章转自http://www.cnblogs.com/chry/p/6240965.html 1. 问题的现象 比如在webConfig中定义了一个viewResolver public class ...
- web项目——javax.servlet.ServletException: Circular view path [registerForm]
报错: 控制台输出: 三月 21, 2019 10:12:32 上午 org.springframework.web.servlet.PageNotFound noHandlerFound 警告: N ...
- Circular view path [mydemo]: would dispatch back to the current handler URL [/mydemo] again. Check your ViewResolver setup!
简单创建一个springboot工程 pom.xml <?xml version="1.0" encoding="UTF-8"?><proje ...
- 【docker】docker部署spring boot项目在服务器上
IDE:idea 工具:docker spring boot:2.0.1 ======================================== 简单记录一下流程,以供参考: 第一步:首先得 ...
- Myeclipse下使用Maven搭建spring boot项目
开发环境:Myeclipse2017.JDK1.6.Tomcat 8.0.Myeclipse下使用Maven搭建spring boot项目,详细过程如下: 1. New -> Project.. ...
- docker部署spring boot项目在服务器上
IDE:idea 工具:docker spring boot:2.0.1 ======================================== 简单记录一下流程,以供参考: 第一步:首先得 ...
- SpringBoot 报错: Circular view path [readingList] 解决办法
spring boot报错: Circular view path [readingList]: would dispatch back to the current handler URL [/re ...
随机推荐
- 分布式通信框架RMI
1.RPC概念: Remote procedure call protocal,远程过程调用协议,一般用来实现部署在不同机器上的系统之间的方法调用, 使得程序能够像访问本地系统资源一样,通过网络传输去 ...
- Qt 学习之路 2(22):事件总结
Qt 学习之路 2(22):事件总结 豆子 2012年10月16日 Qt 学习之路 2 47条评论 Qt 的事件是整个 Qt 框架的核心机制之一,也比较复杂.说它复杂,更多是因为它涉及到的函数众多,而 ...
- poj2823滑动窗口(单调队列)
题目传送门 题意:给你一个长度为n的数列,然后用一个长度为k的窗口去框(k<n)每次保存k这个窗口中的最大值和最小值,输出. 思路:这道题最朴素的on2的做法铁定超时,然后我想过一个nlogn的 ...
- String转不同type的类对象
import org.springframework.beans.SimpleTypeConverter; private Object deserializeValue(Class<?> ...
- tomcat的安装部署
第一步: 先把压缩包拖到知道的目录,解压 tar xf apache-tomcat-8.0.27.tar.gz -C /usr/local/ ln -s /usr/local/apache-tomca ...
- Java字符串拆分和字符串连接
Java字符串拆分/连接 public class LierString{ //------------------------------------------------------------ ...
- /proc下重要路径知识
/proc 虚拟目录,是内存的映射,内核与进程的虚拟文件系统目录/proc/version 内核版本/proc/sys/kernel 系统内核功能/proc/sys/net/ipv4*/proc/cp ...
- vue懒加载 路由 router 的编写(resolve)
如果用import引入的话,当项目打包时路由里的所有component都会打包在一个js中,造成进入首页时,需要加载的内容过多,时间相对比较长.当你用require这种方式引入的时候,会将你的comp ...
- php连接数据库mysql数据库
查找数据 $con = mysqli_connect('localhost', 'root', '', 'mydb'); if (!$con) { die('数据库连接失败' . mysqli_con ...
- linux中mysql,mongodb,redis,hbase数据库操作
.实验内容与完成情况:(实验具体步骤和实验截图说明) (一) MySQL 数据库操作 学生表 Student Name English Math Computer zhangsan lisi 根据上面 ...