spring boot 错误:Check your ViewResolver setup
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的更多相关文章
- 【jsp+jpa】Check your ViewResolver setup!
困扰了好几天的坑 javax.servlet.ServletException: Circular view path [fileupload]: would dispatch back to the ...
- 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 ...
- 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 ...
- 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 ...
- spring boot错误: 找不到或无法加载主类
一:当在eclipse启动spring boot项目时出现问题: springboot错误: 找不到或无法加载主类 解决办法: 1,通过cmd命令行,进入项目目录进行,mvn clean instal ...
- 16. Spring boot 错误页面
默认效果:1).浏览器,返回一个默认的错误页面 1.1 请求头 1.2返回结果 2).如果是其他客户端,默认响应一个json数据 2.1请求头 2.2返回结果 { "timestamp& ...
- 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 ...
- spring boot 错误处理之深度历险
今天终于把 boot 的异常处理完全研究透了: boot提供了很多错误的处理工作.默认情况下,我们会看到一个whiteLabel(白标)的页面. 这个可能不是我们所需.因此我们需要定制.我于是做了个深 ...
- spring boot 错误处理总结
在boot 中, 对404 和 异常 有了额外的处理. 当然,我们可以定制, 如何做呢? 1 写一个继承 ErrorController 的Controller 注意, 这里一定要继承 ErrorC ...
随机推荐
- halcon连续采集图像
dev_close_window()dev_update_window('off')create_bar_code_model ([], [], BarCodeHandle)dev_open_wind ...
- msql修改密码
修改的用户都以root为列.一.拥有原来的myql的root的密码: 方法一:在mysql系统外,使用mysqladmin# mysqladmin -u root -p password " ...
- Selinux相关
SELinux相关的工具 /usr/bin/setenforce 修改SELinux的实时运行模式 setenforce 1 设置SELinux 成为enforcing模式 setenforce 0 ...
- (一)Spring’s MVC Architecture
Spring’s MVC module Spring’s MVC module is based on front controller design pattern followed by MVC ...
- 从零开始构建一个的asp.net Core 项目(一)
最近突发奇想,想从零开始构建一个Core的MVC项目,于是开始了构建过程. 首先我们添加一个空的CORE下的MVC项目,创建完成之后我们运行一下(Ctrl +F5).我们会在页面上看到“Hello W ...
- 使用ConfigFilter
ConfigFilter的作用包括: 从配置文件中读取配置 从远程http文件中读取配置 为数据库密码提供加密功能 1 配置ConfigFilter 1.1 配置文件从本地文件系统中读取 <be ...
- GL_LINES & GL_LINE_STRIP & GL_LINE_LOOP
[GL_LINES] 独立的线段,下式中,p2与p3间没有连线. [GL_LINE_STRIP] 连续的线段,下式中, p2与p3会连成线段. [GL_LINE_LOOP] 参考:<计算机图形学 ...
- 修改 cmd 控制台字体、巧用 FontLink 使中英文独立设置
众所周知,Windows 中 cmd 控制台窗口的字体难看,但是修改注册表是可以实现修改其字体的,但很多很棒的编程字体是没有中文的,所以在显示中文时直接调用了宋体,这绝妙的反差实在是 不忍直视.但是, ...
- Java方法重写与super关键字
----------siwuxie095 方法的重写: (1)在继承中也存在着重写的概念,其实就是子类定义了和父类同名的方法 (2)定义:方法名 ...
- ios-loadView
// 先判断当前控制器是不是从storyBoard中加载,如果是,就会加载stroyBoard的view // 判断是否是xib加载 // 否则创建一个空白的view // 如果重写了此方法, ...