Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Fri Mar 23 10:34:26 CST 2018
There was an unexpected error (type=Internal Server Error, status=500).
Circular view path [index]: would dispatch back to the current handler URL [/home/index] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)

解决办法:

方法1.在请求方法上加注解:@ResponseBody,无需模板文件

@RequestMapping("/home")
@Controller()
public class HomeController {
@ResponseBody
@RequestMapping("/index")
public String index() {
return "index";
}
}
方法2. 用thymeleaf模板
在pom.xml的dependencies元素内加静态模板依赖
    <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>

在resources/templates/创建html模板文件,文件名与请求方法return的字符串一样,扩展名html: index.html

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<p th:text="${data}"></p>
</body>
</html>
@RequestMapping("/home")
@Controller()
public class HomeController {
@RequestMapping("/index")
public String index(HashMap<String,Object> map) {
map.put("data","index.html");
return "index";
}
}
												

spring boot 错误:Check your ViewResolver setup的更多相关文章

  1. 【jsp+jpa】Check your ViewResolver setup!

    困扰了好几天的坑 javax.servlet.ServletException: Circular view path [fileupload]: would dispatch back to the ...

  2. Circular view path [home]: would dispatch back to the current handler URL [/home] again. Check your ViewResolver setup!

    Circular view path [home]: would dispatch back to the current handler URL [/home] again. Check your ...

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

  4. javax.servlet.ServletException: Circular view path [index]: would dispatch back to the current handler URL [/pay/index] again. Check your ViewResolver setup!

    2019-08-08 17:12:03.544 ERROR 13748 --- [nio-8080-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Se ...

  5. spring boot错误: 找不到或无法加载主类

    一:当在eclipse启动spring boot项目时出现问题: springboot错误: 找不到或无法加载主类 解决办法: 1,通过cmd命令行,进入项目目录进行,mvn clean instal ...

  6. 16. Spring boot 错误页面

      默认效果:1).浏览器,返回一个默认的错误页面 1.1 请求头 1.2返回结果 2).如果是其他客户端,默认响应一个json数据 2.1请求头 2.2返回结果 { "timestamp& ...

  7. Spring Boot错误——SpringBoot 2.0 报错: Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

    背景 使用Spring Cloud搭建微服务,服务的注册与发现(Eureka)项目启动时报错,错误如下 *************************** APPLICATION FAILED T ...

  8. spring boot 错误处理之深度历险

    今天终于把 boot 的异常处理完全研究透了: boot提供了很多错误的处理工作.默认情况下,我们会看到一个whiteLabel(白标)的页面. 这个可能不是我们所需.因此我们需要定制.我于是做了个深 ...

  9. spring boot 错误处理总结

    在boot 中, 对404  和 异常 有了额外的处理. 当然,我们可以定制, 如何做呢? 1 写一个继承 ErrorController 的Controller 注意, 这里一定要继承 ErrorC ...

随机推荐

  1. springmvc基本知识点

    springmvc高级知识:

  2. 201671010140. 2016-2017-2 《Java程序设计》java学习第十五周

    java学习第十五周 Java的GUI界面设计,框架以及主要部件填充,归置,布局管理,在第十一章和第十二章进行了系统的学习,在这两章的知识奠基下,可以简单的构造一个GUI用户界面,在两周的学习后,可以 ...

  3. Perl 引用:引用就是指针,Perl 引用是一个标量类型可以指向变量、数组、哈希表(也叫关联数组)甚至子程序。

    Perl 引用引用就是指针,Perl 引用是一个标量类型可以指向变量.数组.哈希表(也叫关联数组)甚至子程序,可以应用在程序的任何地方. 1.创建引用1.使用斜线\定义变量的时候,在变量名前面加个\, ...

  4. C#根据url生成唯一的key

    根据url生成唯一的idkey,记录并分享: public class UrlToUniqueKey { ); , ] { { 0L, 0L }, { -4611686018427387904L, - ...

  5. 字符串匹配——C++使用Regex

    需要#include  < regex >   匹配 regex_match ("subject", std::regex("(sub)(.*)") ...

  6. CloudStack tomcat集成方式分析

    CloudStack 的server.xml和tomcat6.conf都是软连接   CloudStack 在执行脚本时报异常如下:   修改vim /etc/sudoers文件,具体如下     以 ...

  7. spring4-2-bean配置-4-bean之间的关系

  8. Python binascii

    Python binascii模块 Python binascii模块 用处 包含的函数 相关内置函数 code使用示例 转载请标明出处(http://blog.csdn.net/lis_12/art ...

  9. Ubuntu14.04下FTP服务器的搭建配置 标签: ubuntuftp服务器虚拟机 2017-06-13 15:24 161人阅读 评

    首先说明一下,我是在虚拟机中装的Ubuntu14.04,物理机是Win10,最初只是为了在两个系统间传输文件才在Ubuntu中安装了ftp服务器,从Windows端登陆其即可.最初也是按照网上的各种教 ...

  10. NodeJS下的阿里云企业邮箱邮件发送问题

    还没有到11点,再顺带发一个上次碰到NodeJS的邮箱插件nodeMailer不支持阿里云邮件问题. 网上很多资料都默认使用QQ之类的邮箱,因为nodeMailer默认添加了QQ之类的SMTP地址,但 ...