错误:不能返回页面,只返回字符串。

原因:在controller中使用了注解@RestController

修改:修改注解为@Controller

@Controller

分析:

RestController = Controller + ResponseBody.加上RestController,返回的内容是你return中的内容,如果是return "Hello World",页面显示的就是Hello World。加上Controller,返回的是return中对应的页面,比如return “hello”,页面的名称是hello。

http://blog.csdn.net/weixin_38303684/article/details/78024891

这篇文章解释还可以。

这个

这个modelandview这个可以进行跳转:

http://www.cnblogs.com/rocky-AGE-24/p/5153760.html

下面的方法实验未通过:

@RestController的使用(本人实验未通过)

http://www.cnblogs.com/EasonJim/p/7459486.html

分析:

Spring MVC项目中页面重定向一般使用return "redirect:/other/controller/";即可。而Spring Boot使用了@RestController注解,上述写法只能返回字符串

解决方法如下:

将一个HttpServletResponse参数添加到处理程序方法然后调用response.sendRedirect("some-url");

例子:

springboot集成thymeleaf中遇到的问题的更多相关文章

  1. springboot集成thymeleaf中遇到不能反悔页面,只能反悔字符串

    错误:::::不能返回页面,只能返回字符串 原因::::在controller中使用了注解@RestController 修改注解为:@Controller 分析: RestController = ...

  2. Springboot 集成 Thymeleaf 及常见错误

    Thymeleaf模板引擎是springboot中默认配置,与freemarker相似,可以完全取代jsp,在springboot中,它的默认路径是src/main/resources/templat ...

  3. 九、SpringBoot集成Thymeleaf模板引擎

    Thymeleaf咋读!??? 呵呵,是不是一脸懵逼...哥用我的大学四级英文知识告诉你吧:[θaimlif]. 啥玩意?不会音标?...那你就这样叫它吧:“赛母李府”,大部分中国人是听不出破绽的.. ...

  4. SpringBoot 集成MyBatis 中的@MapperScan注解

    SpringBoot 集成MyBatis 中的@MapperScan注解 2018年08月17日 11:41:02 文火慢炖 阅读数:398更多 个人分类: 环境搭建 在SpringBoot中集成My ...

  5. SpringBoot集成thymeleaf(自定义)模板中文乱码的解决办法

    楼主今天在学习SpringBoot集成thymelaf的时候报了中文乱码的错误,经过网上的搜索,现在得到解决的办法,分享给大家: package com.imooc.config; import or ...

  6. Springboot集成Thymeleaf

    Thymeleaf 官方解释: Thymeleaf是一个用于web和独立环境的现代服务器端Java模板引擎. Thymeleaf的主要目的是将优雅的自然模板引入到您的开发工作流中——以使HTML可以在 ...

  7. SpringBoot集成Thymeleaf模板引擎

    简单介绍 目前在JavaEE领域有几中比较常用的模板引擎,分别是Jsp.Velocity.Freemarker.Thymeleaf,对Freemark语法不是特别熟悉,不过对于前端页面渲染效率来说,j ...

  8. spring-boot集成thymeleaf。

    thymeleaf是前台页面展示,原来一直是jsp,jsp中包含很多服务器端的逻辑,逐渐淘汰.同样功能的还有freemarker.孰好孰坏不予评价,只做简单实现. 1.基本思路 (1)pom.xml中 ...

  9. SpringBoot集成Thymeleaf发送Html邮件报错

    由于业务需求需要使用Thymeleaf作为模板发送Html邮件,开发调试过程中发生以下错误 org.thymeleaf.exceptions.TemplateInputException: Error ...

随机推荐

  1. 服务器返回中文乱码的情况(UTF8编码 -> 转化为 SYSTEM_LOCALE 编码)

    服务器乱码 转换使用如下方法 入惨{“msg”} -> utf8编码 -> 转化为 SYSTEM_LOCALE 编码 -> 接受转换后的参数 "sEncoding" ...

  2. sparksql读写hbase

    //写入hbase(hfile方式) org.apache.hadoop.hbase.client.Connection conn = null; try { SparkLog.debug(" ...

  3. 1053 Path of Equal Weight (30 分)(树的遍历)

    题目大意:给出树的结构和权值,找从根结点到叶子结点的路径上的权值相加之和等于给定目标数的路径,并且从大到小输出路径 #include<bits/stdc++.h> using namesp ...

  4. POJ 1739 Tony's Tour(插头DP)

    Description A square township has been divided up into n*m(n rows and m columns) square plots (1< ...

  5. 哈希表 STL map

    计数排序时我们使用一个数组来记录出现的数字的次数,而当数据范围太大时,无法建立一个那么大地数组(而且可能空间利用率很低,太浪费),此时可以改用hash table . binary search tr ...

  6. servlet转发和重定向

    1 转发 RequestDispatcher getRequestDispatcher(java.lang.String path) 1)地址栏不会改变 2)转发只能转发到当前web应用内的资源 3) ...

  7. IOS开发NSBundle使用

    bundle是一个目录,其中包含了程序会使用到的资源. 这些资源包含了如图像,声音,编译好的代码,nib文件(用户也会把bundle称为plug-in). 对应bundle,cocoa提供了类NSBu ...

  8. windows批处理学习---01

    一. 标记符号: CR(0D) 命令行结束符 Escape(1B) ANSI转义字符引导符 Space() 常用的参数界定符 Tab() ; = 不常用的参数界定符 + COPY命令文件连接符 * ? ...

  9. 【Linux】- apt-get命令

    apt-get,是一条linux命令,适用于deb包管理式的操作系统,主要用于自动从互联网的软件仓库中搜索.安装.升级.卸载软件或操作系统. Advanced Package Tool,又名apt-g ...

  10. Android------去除标题栏

    这里暂时只给出一种方法,在java代码中去除 1.继承Activity 在onCreate方法中 getWindow().setFlags(WindowManager.LayoutParams.FLA ...