作者:陈苏女士 | 来源:互联网 | 2023-10-10 08:20
thymeleaf 内联表达式
*******************
内联表达式
**************
文本内联
th:text ==> [[ .. ]]
Hello, [[${session.user.name}]]!
Hello, Sebastian!
th:utext ==> [( .. )]
The message is "[(${msg})]"
The message is
禁用内联
A double array looks like this: [[1, 2, 3], [4, 5]]!
**************
Javascript 内联
**************
css 内联
*******************
示例
**************
controller 层
HelloController
@RestController
public class HelloController {
@RequestMapping("/hello")
public ModelAndView hello(ModelAndView mv){
String info="hello 瓜田李下";
String value="海贼王";
String className="background-color";
String color="green";
mv.addObject("info",info);
mv.addObject("value",value);
mv.addObject("className",className);
mv.addObject("color",color);
mv.setViewName("index");
return mv;
}
}
**************
前端页面
index.html
xmlns:th="http://www.thymeleaf.org" xmlns:sec="https://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
使用内联:[[${info}]]
禁用内联:[[${info}]]
name:
瓜田李下
*******************
使用测试
本文地址:https://blog.csdn.net/weixin_43931625/article/details/107895702