使用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问题解决的更多相关文章

  1. Spring boot项目maven的profile多环境配置不自动替换变量的问题解决

    Spring boot项目maven的profile多环境配置不自动替换变量的问题解决   在网上找了好久,配置都很简单,可是我的程序就是不能自动替换变量,最终单独测试,发现原来是引用spring b ...

  2. 如何在Spring MVC Test中避免”Circular view path” 异常

    1. 问题的现象 比如在webConfig中定义了一个viewResolver public class WebConfig extends WebMvcConfigurerAdapter { //配 ...

  3. 如何在Spring MVC Test中避免”Circular view path” 异常(转)

    文章转自http://www.cnblogs.com/chry/p/6240965.html 1. 问题的现象 比如在webConfig中定义了一个viewResolver public class ...

  4. web项目——javax.servlet.ServletException: Circular view path [registerForm]

    报错: 控制台输出: 三月 21, 2019 10:12:32 上午 org.springframework.web.servlet.PageNotFound noHandlerFound 警告: N ...

  5. 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 ...

  6. 【docker】docker部署spring boot项目在服务器上

    IDE:idea 工具:docker spring boot:2.0.1 ======================================== 简单记录一下流程,以供参考: 第一步:首先得 ...

  7. Myeclipse下使用Maven搭建spring boot项目

    开发环境:Myeclipse2017.JDK1.6.Tomcat 8.0.Myeclipse下使用Maven搭建spring boot项目,详细过程如下: 1. New -> Project.. ...

  8. docker部署spring boot项目在服务器上

    IDE:idea 工具:docker spring boot:2.0.1 ======================================== 简单记录一下流程,以供参考: 第一步:首先得 ...

  9. SpringBoot 报错: Circular view path [readingList] 解决办法

    spring boot报错: Circular view path [readingList]: would dispatch back to the current handler URL [/re ...

随机推荐

  1. windwos-sshfs

    从 http://www.jianshu.com/p/d79901794e3d 转载 目的 最近因为需要在linux虚拟机里进行开发程序,虽然在linux里有超强的编辑器vim,但vim开发html前 ...

  2. [Android UI]View基础知识

    一.简介 在安卓中,View代表视图,是安卓中十分重要的一个概念,重要程度不亚于四大组件,用户每时每刻都在与View打交道,包括展示数据.事件传递等.因此,熟练掌握View的应用以及原理是Androi ...

  3. KM算法(理解篇)

    转载:https://www.cnblogs.com/logosG/p/logos.html(很好,很容易理解) 一.匈牙利算法 匈牙利算法用于解决什么问题? 匈牙利算法用于解决二分图的最大匹配问题. ...

  4. IP地址概念

    1.1  IP地址概念 什么是IP地址:由32位二进制数组成,划分成4组,每组八位: 为了便于人类识别记忆,IP地址表现形式为 "点分十进制" 二进制数与十进制数的转换关系:00 ...

  5. Go语言基础之17--Redis基本操作

    一.介绍与连接 1.1 介绍 使用第三方的redis库, github.com/garyburd/redigo/redis github地址:https://github.com/gomodule/r ...

  6. SUSE12Sp3安装配置.net core 生产环境(2)-安装.NET Core 2.2.1 runtime 并运行.NET代码

    1.安装libicu依赖 1.在线安装 sudo mkdir /usr/local/dotnet #创建目录 cd /usr/local/dotnet sudo wget https://downlo ...

  7. spring boot——关于一个Mysql主键的问题

    问题是这样的: 我现在有一个被@Entity标记的类TimeLine,其中id为主键. TimeLineController中有一个接收post请求的add()方法,这个方法会接受客户端传来的一个表单 ...

  8. windows 7 下安装VMWARE 和 red-hat 7 64bit

    按F2 进入BIOS: 在inter virtualization technology 选择YES 就可以安装linux 64bit 操作系统了 https://blog.csdn.net/coco ...

  9. VUE验证器哪家强? VeeValidate absolutely!

    VUE验证器哪家强? VeeValidate absolutely! vee-validate表单验证用法 github地址:https://github.com/baianat/vee-valida ...

  10. Fortran和C的编译器PGI部署

    平台信息 Description: CentOS Linux release 7.6.1810 (Core) 安装步骤 获取PGCC:社区版是免费的,自带license.dat 解压下载的压缩包:ta ...