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 ...
随机推荐
- leetcode819
public class Solution { public string MostCommonWord(string paragraph, string[] banned) { //"a, ...
- **类的起源--type
通过type类的实例化,创建新的类. #!/usr/bin/env python # Version = 3.5.2 def func(self): print('Hello,{}'.format(s ...
- 【Consul】Consul实践指导-配置文件
Agent有各种各样的配置选项,这些配置选项可以通过命令行参数的方式设定,也可用通过配置文件的方式设定--所有的配置选项都是可选的,当然也是有默认值的. 当加载配置选项时,consul是按照词典顺序从 ...
- centos安装rvm报错@curl -L get.rvm.io | bash -s stable fails on cent OS
It is a security feature introduced in the latest version of RVMhttps://github.com/wayneeseguin/rvm/ ...
- autofs文件自动挂载系统
为了自己使用方便,利用iso文件制作了自己的rhel6.4的yum源,每次都手动进行mount,十分不便 后来在/etc/rc.local中写入了mount命令,方便多了. 时间一久,发现新的问题出现 ...
- Ubuntu更新命令 <转>
apt-cache search package 搜索包 apt-cache show package 获取包的相关信息,如说明.大小.版本等 sudo apt-get install package ...
- com.mysql.jdbc.exceptions.jdbc4.CommunicationsException/com.atomikos.datasource.ResourceException异常解决
tomcat+mysql部署,每天早晨第一次访问web项目,出现mysql的连接timeout异常:com.mysql.jdbc.exceptions.jdbc4.CommunicationsExce ...
- Ros学习——movebase源码解读之amcl
1.amcl的cmakelists.txt文件 add_executable(amcl src/amcl_node.cpp) target_link_libraries(amcl amcl_sens ...
- App审核被拒(后台定位被拒,ipv6被拒,广告标示被拒的解决方案)
ipv6被拒问题描述: 解决方案支持ipv6 1)搭建ipv6 环境,搭建好的ipv6 ,环境会有一个共享wifi, 具体如何搭建ipv6测试环境参考本地如何搭建IPv6环境测试你的APP2)app连 ...
- 学习h5(开始)
webstorm 下载地址:http://www.sdifenzhou.com/6176.html webstorm注册码: 43B4A73YYJ-eyJsaWNlbnNlSWQiOiI0M0I0QT ...