使用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. jeesite 框架的简单应用

    个人觉得比较完善的一个讲解jeesite的网站 https://www.w3cschool.cn/jeesite/ jeesite官网 http://jeesite.com/ 公司项目都是基于jees ...

  2. 去除List集合中的重复值(四种好用的方法)

    最近项目中需要对list集合中的重复值进行处理,大部分是采用两种方法,一种是用遍历list集合判断后赋给另一个list集合,一种是用赋给set集合再返回给list集合. 但是赋给set集合后,由于se ...

  3. html 一些坑。。。

    margin-left 和 margin-right 才能够使用 auto top 和 bottom 不可以 在网页设计中...通常给img 父容器 一个 宽度...同时 ,指定 img width= ...

  4. [CF1051F]The Shortest Statement (LCA+最短路)(给定一张n个点m条有权边的无向联通图,q次询问两点间的最短路)

    题目:给定一张n个点m条有权边的无向联通图,q次询问两点间的最短路 n≤100000,m≤100000,m-n≤20. 首先看到m-n≤20这条限制,我们可以想到是围绕这个20来做这道题. 即如果我们 ...

  5. Python数据分析之pandas学习(基础操作)

    一.pandas数据结构介绍 在pandas中有两类非常重要的数据结构,即序列Series和数据框DataFrame.Series类似于numpy中的一维数组,除了通吃一维数组可用的函数或方法,而且其 ...

  6. 阿里Java开发规约(1)

    本文是对阿里插件中规约的详细解释一,关于插件使用,请参考这里 1. ArrayList的subList结果不可强转成ArrayList,否则会抛出ClassCastException异常. 说明:禁止 ...

  7. Idea如何设置代码超出长度限制时自动换行

    在[File]-->[Settings]-->[Code Sytle]中勾选[Wrap on typing]选项

  8. 创建本地Git并提交到码云

    概述 安装Git,使用Git Bash创建本地Git全局用户名,提交远程代码时将以此用户名显示git config --global --replace-all user.email "it ...

  9. File "<ipython-input-20-ac8d4b51998e>"

    环境:Python 3.6 word = "Jesse" ") File "<ipython-input-20-ac8d4b51998e>" ...

  10. JavaSE---反射(未完待续)

    1.概述 1.1 Java程序中许多对象在运行时会出现2种类型:编译时类型.运行时类型: eg:Person  person=new Student(); 这行代码在编译时为Person类型,运行时为 ...