thymeleaf常用标签 thymeleaf:字符串Strings常见的使用方法


判断是不是为空:null: 

不为空 
为空 
判断是不是为空字符串: “” 
空的 
判断是否相同: 
相同于jack, 
相同于ywj, 
不相同于jack, 
不存在设置默认值: 
 
是否包含(分大小写): 
包ez 
包j 
是否包含(不分大小写) 
包j 
同理。。。下面的和JAVA的String基本一样。。。。不笔记解释,官网有

${#strings.startsWith(name,'o')} 
${#strings.endsWith(name, 'o')} 
${#strings.indexOf(name,frag)}// 下标 
${#strings.substring(name,3,5)}// 截取 
${#strings.substringAfter(name,prefix)}// 从 prefix之后的一位开始截取到最后,比如 (ywj,y) = wj, 如果是(abccdefg,c) = cdefg//里面有2个c,取的是第一个c 
${#strings.substringBefore(name,suffix)}// 同上,不过是往前截取 
${#strings.replace(name,'las','ler')}// 替换 
${#strings.prepend(str,prefix)}// 拼字字符串在str前面 
${#strings.append(str,suffix)}// 和上面相反,接在后面 
${#strings.toUpperCase(name)} 
${#strings.toLowerCase(name)} 
${#strings.trim(str)} 
${#strings.length(str)} 

${#strings.abbreviate(str,10)}//  str截取0-10位,后面的全部用…这个点代替,注意,最小是3位

 

 

常用th标签都有那些?


关键字      功能介绍        案例
th:id      替换id         
th:text     文本替换        

description


th:utext    支持html的文本替换   

conten


th:object    替换对象        

th:value    属性赋值        
th:with    变量赋值运算        

th:style    设置样式            th:style="'display:' + @{(${sitrue} ? 'none' : 'inline-block')} + ''"
th:onclick    点击事件          th:οnclick="'getCollect()'"
th:each    属性赋值            tr th:each="user,userStat:${users}">
th:if    判断条件            
th:unless    和th:if判断相反        
Login
th:href    链接地址              Login />
th:switch    多路选择 配合th:case 使用   

th:case    th:switch的一个分支        

User is an administrator


th:fragment    布局标签,定义一个代码片段,方便其它地方引用   

th:include    布局标签,替换内容到引入的文件    />
th:replace    布局标签,替换整个标签到引入的文件   

th:selected    selected选择框 选中    th:selected="(${xxx.id} == ${configObj.dd})"
th:src    图片类地址引入          App Logo
th:inline    定义js脚本可以使用变量   

你可能感兴趣的:(thymealf)