为了账号安全,请及时绑定邮箱和手机立即绑定

SpringBoot,Thymeleaf th:text=${name}获取不到后端传过来的值

SpringBoot,Thymeleaf th:text=${name}获取不到后端传过来的值

临摹微笑 2018-09-04 09:09:23
后台代码:@Controller // 标明这是一个SpringMVC的Controller控制器@RequestMapping("/syj")public class TestJspController {@RequestMapping("/helloa")public ModelAndView gg2(ModelAndView mv,HttpServletRequest request,HttpSession session ){session.setAttribute("kk", "金合欢花或或");request.setAttribute("key", "神学集团克东");mv.setViewName("home/aaa");mv.addObject("title","欢迎使用Thymeleaf!");return mv;}前台:<!DOCTYPE html><html xmlns:th="http://www.thymeleaf.org" ><head><title>Good Thymes Virtual Grocery</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head><body><div th:text="${session.kk}">测试session</div><h1 th:inline="text" ><p th:text="${key}" th:remove="tag">Welcome to our grocery store!</p></h1><p th:text="${title}">Welcome to our grocery store!</p><h1><span th:text="${key}" th:remove="tag">title</span><small th:text="${key}" >Subtitle</small></h1></body>
查看完整描述

1 回答

?
慕的地8271018

TA贡献1796条经验 获得超4个赞

你的前台文件没有,th:text=${name}
是不是写错了?

查看完整回答
反对 回复 2018-09-28
  • 1 回答
  • 0 关注
  • 16081 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信