效果显示
controller 代码演示
/**
* 类描述:查询主页面的图片信息和标题文字
*
* @ClassName UserController
* @Description TODO
* @Author 10464
* @Date 2021/7/6 17:17
* @Version 1.0
* @return
*/
@RequestMapping(value = "/zyhome")
public ModelAndView home(Model model){
ModelAndView view = new ModelAndView();
Map<Object, Object> userhom = userService.zhuyhome();//map 查询数据
view.addObject("userhome",userhom);//保存数据
view.setViewName("index");//返回前端页面
return view;
}
application.properties
# 表示返回页面
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.servlet.content-type=text/html
spring.thymeleaf.encoding=utf-8
spring.thymeleaf.mode=LEGACYHTML5
spring.thymeleaf.cache=false
spring.mvc.static-path-pattern=/**
spring.resources.static-locations=classpath:/static/
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title th:text="${userhome?.get('biaotia')}">Title</title>
<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
</head>
<body>
//取值方式
<span><p th:text="${userhome?.get('biaotid')}"></p></span>
</body>
</html>