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 ...
随机推荐
- javascript 中function(){}(),new function(),new Function(),Function
和java比起来,javascript真的是松散的无以复加,不过这也让我们在无聊之余,有精力去探讨一些复杂的应用,从而在开发之路上,获得一些新的想法. javascript中的类的构造 javascr ...
- pytorch 迁移学习[摘自官网]
迁移学习包含两种:微调和特征提取器. 微调:对整个网络进行训练,更新所有参数 特征提取器:只对最后的输出层训练,其他层的权重保持不变 当然,二者的共性就是需要加载训练好的权重,比如在ImageNet上 ...
- spring自定义 xsd 位置
与元素类型 "beans" 相关联的属性 "xsi:schemaLocation" 的前缀 "xsi" 未绑定. 解决办法:(绿色字体) & ...
- AJAX使用说明书 基础
AJAX简介 什么是AJAX AJAX(Asynchronous Javascript And XML)翻译成中文就是“异步Javascript和XML”.即使用Javascript语言与服务器进行异 ...
- Gym - 101615J Grid Coloring DP 2017-2018 ACM-ICPC Pacific Northwest Regional Contest (Div. 1)
题目传送门 题目大意: 给出n*m的网格,有红蓝两种颜色,每个格子都必须被染色,当一个格子被染成蓝色后,这个格子左上方的一块都必须被染成蓝色,问最后的方案数量. 思路: 按照题目条件,如果有一个格子被 ...
- CodeForces - 984C——Finite or not?分数整除问题(数论,gcd)
题目传送门 题目描述:给你一个p/q,让你求在b进制下,这个小数是不是有限小数. 思路: 先来膜拜一个大神的博客,如何求小数的二进制表达,(感谢博主肘子zhouzi).然后小数的其他进制表达也一样. ...
- GitLab 遇到的坑
Job for postfix.service failed because the control process exited with error [zbb@storage1 ~]$ sudo ...
- Observable Flowable Test
package com.test.rxjava; import java.time.Duration; import java.time.Instant; import java.util.Linke ...
- Android + Appium 自动化测试完整的环境配置及代码详解
环境的的搭建 参考大神博客:https://www.cnblogs.com/fnng/p/4540731.html 该博客有一套详细的入门教程,奈何时间有点久远有些东西不能用了,但是参考价值还是有滴. ...
- /etc目录下重要的目录和文件
牢记: 1.*/etc/sysconfig/network-scripts/ifcfg-eth0 网卡的配置信息 重启网卡:1)/etc/init.d/network restart(所有网卡) ...