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 ...
随机推荐
- HTTP协议和WebSocket协议(一)
转自:https://www.jianshu.com/p/0e5b946880b4# HTTP HTTP的地址格式如下: http_URL = "http:" "//&q ...
- POJ1051 P,MTHBGWB
题目来源:http://poj.org/problem?id=1051 题目大意: Morse密码里每个字母用长度不定的点和线来表示,一条信息中字母的编码之间用空隙隔开.下表为Morse密码的编码表: ...
- Unity 使用小技巧
本文介绍我遇到过我Unity使用小技巧,有了这些技巧,项目做起来,溜得飞起 1.快速设置相机的位置 2.固定面板
- 设置IIS,使客户端访问服务器上的文件
1.打开IIS控制器——"运行-cmd-inetmgr-回车“ 2.选中要设置的网站 3.右键,添加虚拟目录 4.如上图所示,在别名处输入文件目录的名称,物理路径要选择文件在磁盘上的存储根目 ...
- eclipse使用STS插件 报错:SocketTimeoutException: Read timed out
新建boot项目后,提示: SocketTimeoutException: Read timed out 解决: 在eclipse.ini末尾,追加: -Djava.net.preferIPv4Sta ...
- thinkPHP Model的操作
1.建立一个表 create table Demo( -> id int, ), -> age int, ) -> ); 2.新增数据 2.1面向过程的风格 $d = $a-> ...
- ubuntu 修改hostname
1.sudo gedit /etc/hostname 2. 修改成你的新名字,例如 SS1 3. 保存,退出 3. sudo gedit /etc/hosts 4修改成心的名字 SS1 5. 保存,退 ...
- Notepad++实用插件
说明: Converter: 编码转换工具,ascii2hex,hex2ascii DoxyIt: 添加文件或者函数注释比较方便 DSpellCheck: 拼写检查 MIME Tools: 将Base ...
- Java基础04-数据的输入
1.为什么要有数据的输入? 实现人机进行交互 2.什么是数据的输入? 利用扫描仪Scanner进行数据输入 3.怎么使用扫描仪Scanner? (1)放在类声明之前,引入扫描仪 import java ...
- .NET平台下使用C#连接各种数据库
在.NET平台下,通常我们需要连接不同的数据库,这就需要我们配置连接字符串以及提供常用的class进行数据存取. 1.C#连接Access @"Provider=Microsoft.ACE. ...