springboot 传值到页面
<!DOCTYPE html>
2 <html>
3 <head lang="en">
4 <meta charset="UTF-8" />
5 <title></title>
6 </head>
7 <body>
8 <h1 th:text="${host}">Hello World</h1>
9 </body>
10 </html>
编写HelloController.java

package com.springboot.test; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping; @Controller
public class HelloController { @RequestMapping("/")
public String index(ModelMap map) {
// 加入一个属性,用来在模板中读取
map.addAttribute("host", "Spring test");
// return模板文件的名称,对应src/main/resources/templates/index.html
return "index";
}
}
springboot 传值到页面的更多相关文章
- 新建SpringBoot项目运行页面报错Whitelabel Error Page This application has no explicit mapping for /error, so yo
新建SpringBoot项目运行页面报错Whitelabel Error Page This application has no explicit mapping for /error, so yo ...
- SpringBoot自定义错误页面,SpringBoot 404、500错误提示页面
SpringBoot自定义错误页面,SpringBoot 404.500错误提示页面 SpringBoot 4xx.html.5xx.html错误提示页面 ====================== ...
- SpringBoot thymeleaf模板页面没提示,SpringBoot thymeleaf模板插件安装
SpringBoot thymeleaf模板插件安装 SpringBoot thymeleaf模板Html页面没提示 SpringBoot thymeleaf模板页面没提示 SpringBoot t ...
- SpringMVC:后台将List转为Json,传值到页面
一.JSP页面 <body> <form name="test" action="getAllStudent" method="po ...
- springboot自定义错误页面
springboot自定义错误页面 1.加入配置: @Bean public EmbeddedServletContainerCustomizer containerCustomizer() { re ...
- Springboot - 自定义错误页面
Springboot 没找到页面或内部错误时,会访问默认错误页面.这节我们来自定义错误页面. 自定义错误页面 1.在resources 目录下面再建一个 resources 文件夹,里面建一个 err ...
- springboot结合jsp页面详解
第一次写博客,其实就是为了约束我自己,写的不一定对,互相借鉴吧!有不对的地方请多多指正,谢谢! 今天我们来看一下springboot结合jsp页面的具体操作: 1.首先我们先看一下目录结构 由上面我们 ...
- springboot传值踩坑
由于我现在写的项目都是前后端分离的,前端用的是vue,后端springboot,于是前后端传值的问题就是一个比较重要的问题,为此我还特意去学了一下vue的传值,其实就是用一个axios组件,其实就是基 ...
- SpringBoot定制错误页面
(1)有模板引擎的情况下,例如404错误,将会在thymeleaf的templates的error下寻找404.html,如果找不到再寻找4xx.html *所有4开头的错误状态码如果找不到特定的ht ...
随机推荐
- 线段树(segment tree)
线段树是一种二叉搜索树,它的每一个结点对应着一个区间[L, R],叶子结点对应的区间就是一个单位区间,即L == R.对于一个非叶子结点[L, R],它的左儿子所表示的区间是[L, (L +R)/2] ...
- python学习笔记02--列表和元组
一.简介 数据结构是通过某种方式组织在一起的数据元素的集合. 序列是python中最基本的数据结构,python中包含6种内建的序列,分别是列表.元组.字符串.Unicode字符串.buffer对象和 ...
- [转]微擎人人商城m()函数调用model方法
本文转自:http://yangjunwei.com/a/3177.html 微擎人人商城p()函数可内部调用任意插件的函数 http://yangjunwei.com/a/3216.html
- 使用iconv进行编码gb2312转utf8 转码失败的坑
iconv 编码gb2312转utf8 转码失败的坑 使用背景 项目中使用thrift进行C#程序调用c++接口,其中的协议是通过json进行传输的,由于默认thrift使用utf8进行传输,而C#和 ...
- table垂直居中
th,td{ text-align:center;/** 设置水平方向居中 */ vertical-align:middle/** 设置垂直方向居中 */ }
- React 入门学习笔记整理(八)—— todoList
APP.js import React, { Component,createRef,Fragment} from 'react'; import Todos from './components/t ...
- Google Chrome 下载&绿化&增强
Chrome下载 Google Chrome 已经可以在线更新,虽然比较慢! 国内常用的更新地址有两处:chromedownloads 和 shuax(耍下): https://www.chromed ...
- android一个倾斜的TextView,适用于标签效果
描述: android一个倾斜的TextView,适用于标签效果 应用截图: 使用说明: <com.haozhang.lib.SlantedTextView android:layout_wid ...
- Vue组件的基础用法(火柴)
前面的话 组件(component)是Vue最强大的功能之一.组件可以扩展HTML元素,封装可重用的代码,根据项目需求,抽象出一些组件,每个组件里包含了展现.功能和样式.每个页面,根据自己的需要,使用 ...
- linux中使用nfs共享文件
NFS需要使用远程过程调用 (RPC),也就是说,我们并不是只要启动NFS, 还需要启动RPC这个服务 服务器端 CentOS 7.4 ip:172.16.0.1 共享/tmp目录 共享/data目录 ...