spring boot与thymeleaf页面传参两种方式
来源:互联网 发布:oracle数据库有可视化 编辑:程序博客网 时间:2024/06/05 12:43
1.利用ModelAndView对象向页面传参
@RequestMapping("/index/{p}.html")
public ModelAndView index(@PathVariable int p,String keyword){
ModelAndView view = new ModelAndView();
view.setViewName("index");
//因为用了spring boot缓存,sb是用返回值做缓存,所以service再次返回了pageQuery以缓存查询结果
List<Topic> findTopicsByPage = topicService.findTopicsByPage(p,Const.TOPIC_PAGE_SIZE);
view.addObject("topicPage", findTopicsByPage);
view.addObject("pagename", "首页综合");
return view;
}
2.利用model对象向页面传参
@RequestMapping("/index/{p}.html")
public String index(Model model){
//因为用了spring boot缓存,sb是用返回值做缓存,所以service再次返回了pageQuery以缓存查询结果
List<Topic> findTopicsByPage = topicService.findTopicsByPage(1,Const.TOPIC_PAGE_SIZE);
model.addAttribute("topicPage", findTopicsByPage);
model.addAttribute("pagename", "首页综合");
return "index";
}
- spring boot与thymeleaf页面传参两种方式
- Spring Boot与Thymeleaf集成
- thymeleaf+spring boot 页面hashmap取值
- [spring boot][thymeleaf]spring boot 1.5+ 页面无法找到
- [spring-boot] thymeleaf 热交换
- Spring Boot + Gradle + Thymeleaf
- spring boot 整合 thymeleaf
- spring boot vue Thymeleaf
- spring boot thymeleaf 用法
- Spring Boot使用Thymeleaf
- Spring-Boot thymeleaf异常
- spring-boot集成thymeleaf
- Spring Boot整合thymeleaf
- Spring Boot 页面跳转视图解析Thymeleaf和FreeMarker详解
- Spring Boot学习(四)之web开发渲染页面 -- Thymeleaf
- Spring Boot+Spring Security+Thymeleaf
- Thymeleaf系列一 Spring boot 集成Thymeleaf
- Spring Boot (三) Spring Boot for thymeleaf
- 深入浅出ADX、DSP和SSP
- 清除浏览器缓存的几种方法
- Spring Boot + MyBatis + Freemarker 环境搭建
- c# list 查找重复项 Distinct()方法
- SDUT 2017 Autumn Single Contest K
- spring boot与thymeleaf页面传参两种方式
- xml字符串转换为json对象
- 常用的console 的方法
- 中国海洋大学 软件工程 考研交流
- Python2.x与3.x版本区别
- NoSQL之MongoDB简介
- 又遇IDEA 乱输入代码,也不报错问题,解决后,笔而记之。
- 695. Max Area of Island
- 第九讲 数组排序算法:冒泡排序、选择排序、插入排序及二分查找技术