jstl标签库<c:if>和<c:choose>区别
2016-06-03 13:39
295 查看
遇到一个问题
页面取值时,前面总是有空格,导致标题不居中,以前是这么写的。
<c:if test="${fn:length(data[0].name)>8}">${fn:substring(data[0].name,0,8)}...</c:if>
<c:if test="${fn:length(data[0].name)<=8}">${fn:trim(data[0].name)}</c:if>
后来我改成这样就可以了
<c:choose>
<c:when test="${fn:length(data[0].name)>8}">
${fn:substring(data[0].name,0,8)}...
</c:when>
<c:otherwise>
${fn:trim(data[0].name)}
</c:otherwise>
</c:choose>
页面取值时,前面总是有空格,导致标题不居中,以前是这么写的。
<c:if test="${fn:length(data[0].name)>8}">${fn:substring(data[0].name,0,8)}...</c:if>
<c:if test="${fn:length(data[0].name)<=8}">${fn:trim(data[0].name)}</c:if>
后来我改成这样就可以了
<c:choose>
<c:when test="${fn:length(data[0].name)>8}">
${fn:substring(data[0].name,0,8)}...
</c:when>
<c:otherwise>
${fn:trim(data[0].name)}
</c:otherwise>
</c:choose>
相关文章推荐
- js获取select标签选中的值
- js date 操作
- JavaScript学习笔记一:数据类型和变量
- jstl表达式,前台删除的提示问题
- JavaScript基础——面向对象的程序设计(一)创建对象的几种方式总结
- 自学jsp自定义标签的第一步我过了
- js原型(prototype)和面对对象
- datatable 转换json
- alibaba的FastJson(高性能JSON开发包) json转换
- 使用js模拟点击a链接 无效的解决方案
- javascript常用字符串函数和本地存储
- JS中使用变量保存arguments对象的方法
- SharePoint 2013 Rest and SP.js Copyto and Moveto (Rest 和SP.js 基本用法之 复制和移动文件)
- javascript中的浅复制和深复制
- JavaScript 中的所有数据都是以 64 位浮点型数据(float) 来存储。浮点型数据使用注意事项。全局变量特殊之处
- 判断js变量是否定义,
- [Effective JavaScript 笔记]第24条:使用变量保存arguments对象
- 安卓请求服务器js文件下载到本地,版本号就下载
- js生成指定范围内的随机数
- JS使用eval()动态创建变量的方法