当前位置: 首页 > news >正文

自己做的网站怎么上传到网络/谷歌官网入口

自己做的网站怎么上传到网络,谷歌官网入口,官方网站建设公司,互联网网站建设 选择题在应用程序开发中,如果内容过长,想截取一定长度字符,然后补充"....."jstl1.1引入了一个fn.tld的标签,用于处理字符,如获得字符length,substring,indexof,endWith,lowcase实现截取字符串如:<c:set var"log.logTitle" value"做一个截取字符串长度的测…

在应用程序开发中,如果内容过长,想截取一定长度字符,然后补充"....."
jstl1.1
引入了一个fn.tld的标签,用于处理字符,如获得字符
length,substring,indexof,endWith,lowcase
实现截取字符串

:
<c:set var="log.logTitle" value="
做一个截取字符串长度的测试
"
<c:choose>
<c:when test="${fn:length(log.logTitle) > 10}">
<c:out value="${fn:substring(log.logTitle, 0, 10)}......" />
</c:when>
<c:otherwise>
<c:out value="${log.logTitle}" />
</c:otherwise>
</c:choose>


JSTLStruts的结合(八)

9.7 Functions标签库

称呼Functions标签库为标签库,倒不如称呼其为函数库来得更容易理解些。因为Functions标签库并没有提供传统的标签来为JSP页面的工作服务,而是被用于EL表达式语句中。在JSP2.0规范下出现的Functions标签库为EL表达式语句提供了许多更为有用的功能。Functions标签库分为两大类,共16个函数。

长度函数:fn:length

字符串处理函数:fn:containsfn:containsIgnoreCasefn:endsWithfn:escapeXmlfn:indexOffn:joinfn:replacefn:splitfn:startsWithfn:substringfn:substringAfterfn:substringBeforefn:toLowerCasefn:toUpperCasefn:trim

以下是各个函数的用途和属性以及简单示例。

<chsdate w:st="on" year="1899" month="12" day="30" islunardate="False" isrocdate="False"><span style="mso-bookmark: _Toc134092077"><span style="mso-bookmark: _Toc133721065"><span style="mso-bookmark: _Toc133394916"><strong><span lang="EN-US" style="COLOR: #013366; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-family: Arial">9.7.1</span></strong></span></span></span></chsdate> 长度函数fn:length函数

长度函数fn:length的出现有重要的意义。在JSTL1.0中,有一个功能被忽略了,那就是对集合的长度取值。虽然java.util.Collection接口定义了size方法,但是该方法不是一个标准的JavaBean属性方法(没有get,set方法),因此,无法通过EL表达式“${collection.size}”来轻松取得。

fn:length函数正是为了解决这个问题而被设计出来的。它的参数为input,将计算通过该属性传入的对象长度。该对象应该为集合类型或String类型。其返回结果是一个int类型的值。下面看一个示例。

<%ArrayList arrayList1 = new ArrayList();

arrayList1.add("aa");

arrayList1.add("bb");

arrayList1.add("cc");

%>

<%request.getSession().setAttribute("arrayList1", arrayList1);%>

${fn:length(sessionScope.arrayList1)}

假设一个ArrayList类型的实例“arrayList1”,并为其添加三个字符串对象,使用fn:length函数后就可以取得返回结果为“3”。

<chsdate w:st="on" year="1899" month="12" day="30" islunardate="False" isrocdate="False"><span style="mso-bookmark: _Toc134092078"><span style="mso-bookmark: _Toc133721066"><span style="mso-bookmark: _Toc133394917"><strong><span lang="EN-US" style="COLOR: #013366; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-family: Arial">9.7.2</span></strong></span></span></span></chsdate> 判断函数fn:contains函数

fn:contains函数用来判断源字符串是否包含子字符串。它包括stringsubstring两个参数,它们都是String类型,分布表示源字符串和子字符串。其返回结果为一个boolean类型的值。下面看一个示例。

${fn:contains("ABC", "a")}<br>

${fn:contains("ABC", "A")}<br>

前者返回“false”,后者返回“true”。

<chsdate w:st="on" year="1899" month="12" day="30" islunardate="False" isrocdate="False"><span style="mso-bookmark: _Toc134092079"><span style="mso-bookmark: _Toc133721067"><span style="mso-bookmark: _Toc133394918"><strong><span lang="EN-US" style="COLOR: #013366; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-family: Arial">9.7.3</span></strong></span></span></span></chsdate> fn:containsIgnoreCase函数

fn:containsIgnoreCase函数与fn:contains函数的功能差不多,唯一的区别是fn:containsIgnoreCase函数对于子字符串的包含比较将忽略大小写。它与fn:contains函数相同,包括stringsubstring两个参数,并返回一个boolean类型的值。下面看一个示例。

${fn:containsIgnoreCase("ABC", "a")}<br>

${fn:containsIgnoreCase("ABC", "A")}<br>

前者和后者都会返回“true”。

<chsdate w:st="on" year="1899" month="12" day="30" islunardate="False" isrocdate="False"><span style="mso-bookmark: _Toc134092080"><span style="mso-bookmark: _Toc133721068"><span style="mso-bookmark: _Toc133394919"><strong><span lang="EN-US" style="COLOR: #013366; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-family: Arial">9.7.4</span></strong></span></span></span></chsdate> 词头判断函数fn:startsWith函数

fn:startsWith函数用来判断源字符串是否符合一连串的特定词头。它除了包含一个string参数外,还包含一个subffx参数,表示词头字符串,同样是String类型。该函数返回一个boolean类型的值。下面看一个示例。

${fn:startsWith ("ABC", "ab")}<br>

${fn:startsWith ("ABC", "AB")}<br>

前者返回“false”,后者返回“true”。

<chsdate w:st="on" year="1899" month="12" day="30" islunardate="False" isrocdate="False"><span style="mso-bookmark: _Toc134092081"><span style="mso-bookmark: _Toc133721069"><span style="mso-bookmark: _Toc133394920"><strong><span lang="EN-US" style="COLOR: #013366; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-family: Arial">9.7.5</span></strong></span></span></span></chsdate> 词尾判断函数fn:endsWith函数

fn:endsWith函数用来判断源字符串是否符合一连串的特定词尾。它与fn:startsWith函数相同,包括stringsubffx两个参数,并返回一个boolean类型的值。下面看一个示例。

${fn:endsWith("ABC", "bc")}<br> ${fn:endsWith("ABC", "BC")}<br>

前者返回“false”,后者返回“true”。

<chsdate w:st="on" year="1899" month="12" day="30" islunardate="False" isrocdate="False"><span style="mso-bookmark: _Toc134092082"><span style="mso-bookmark: _Toc133721070"><span style="mso-bookmark: _Toc133394921"><strong><span lang="EN-US" style="COLOR: #013366; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-family: Arial">9.7.6</span></strong></span></span></span></chsdate> 字符实体转换函数fn:escapeXml函数

fn:escapeXml函数用于将所有特殊字符转化为字符实体码。它只包含一个string参数,返回一个String类型的值。

<chsdate w:st="on" year="1899" month="12" day="30" islunardate="False" isrocdate="False"><span style="mso-bookmark: _Toc134092083"><strong><span lang="EN-US" style="COLOR: #013366; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-family: Arial">9.7.8</span></strong></span></chsdate> 字符匹配函数fn:indexOf函数

fn:indexOf函数用于取得子字符串与源字符串匹配的开始位置,若子字符串与源字符串中的内容没有匹配成功将返回“<chmetcnv w:st="on" unitname="”" sourcevalue="1" hasspace="False" negative="True" numbertype="1" tcsc="0"><span lang="EN-US" style="COLOR: black; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-weight: bold">-1</span><span style="COLOR: black; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-bidi-font-weight: bold">”</span></chmetcnv>。它包括stringsubstring两个参数,返回结果为int类型。下面看一个示例。

${fn:indexOf("ABCD","aBC")}<br> ${fn:indexOf("ABCD","BC")}<br>

前者由于没有匹配成功,所以返回-1,后者匹配成功将返回位置的下标,为1

<chsdate w:st="on" year="1899" month="12" day="30" islunardate="False" isrocdate="False"><span style="mso-bookmark: _Toc134092084"><span style="mso-bookmark: _Toc133721072"><span style="mso-bookmark: _Toc133394923"><strong><span lang="EN-US" style="COLOR: #013366; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-family: Arial">9.7.9</span></strong></span></span></span></chsdate> 分隔符函数fn:join函数

fn:join函数允许为一个字符串数组中的每一个字符串加上分隔符,并连接起来。它的参数、返回结果和描述如表9.25所示:

9.25 fn:join函数

参数

描述

array

字符串数组。其类型必须为String[]类型

separator

分隔符。其类型必须为String类型

返回结果

返回一个String类型的值

下面看一个示例。

<% String[] stringArray = {"a","b","c"}; %>

<%request.getSession().setAttribute("stringArray", stringArray);%>

${fn:join(sessionScope.stringArray,";")}<br>

定义数组并放置到Session中,然后通过Session得到该字符串数组,使用fn:join函数并传入分隔符“;”,得到的结果为“a;b;c”。

<chsdate w:st="on" year="1899" month="12" day="30" islunardate="False" isrocdate="False"><span style="mso-bookmark: _Toc134092085"><span style="mso-bookmark: _Toc133721073"><span style="mso-bookmark: _Toc133394924"><strong><span lang="EN-US" style="COLOR: #013366; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-family: Arial">9.7.10</span></strong></span></span></span></chsdate> 替换函数fn:replace函数

fn:replace函数允许为源字符串做替换的工作。它的参数、返回结果和描述如表9.26所示:

9.26  fn:replace函数

参数

描述

inputString

源字符串。其类型必须为String类型

beforeSubstring

指定被替换字符串。其类型必须为String类型

afterSubstring

指定替换字符串。其类型必须为String类型

返回结果

返回一个String类型的值

下面看一个示例。

${fn:replace("ABC","A","B")}<br>

将“ABC”字符串替换为“BBC”,在“ABC”字符串中用“B”替换了“A”。

<chsdate w:st="on" year="1899" month="12" day="30" islunardate="False" isrocdate="False"><span style="mso-bookmark: _Toc134092086"><span style="mso-bookmark: _Toc133721074"><span style="mso-bookmark: _Toc133394925"><strong><span lang="EN-US" style="COLOR: #013366; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-family: Arial">9.7.11</span></strong></span></span></span></chsdate> 分隔符转换数组函数fn:split函数

fn:split函数用于将一组由分隔符分隔的字符串转换成字符串数组。它的参数、返回结果和描述如表9.27所示:

9.27  fn:split函数

参数

描述

string

源字符串。其类型必须为String类型

delimiters

指定分隔符。其类型必须为String类型

返回结果

返回一个String[]类型的值

下面看一个示例。

${fn:split("A,B,C",",")}<br>

将“A,B,C”字符串转换为数组{A,B,C}

<chsdate w:st="on" year="1899" month="12" day="30" islunardate="False" isrocdate="False"><span style="mso-bookmark: _Toc134092087"><span style="mso-bookmark: _Toc133721075"><span style="mso-bookmark: _Toc133394926"><strong><span lang="EN-US" style="COLOR: #013366; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-bidi-font-family: Arial">9.7.12</span></strong></span></span></span></chsdate> 字符串截取函数fn:substring函数

fn:substring函数用于截取字符串。它的参数、返回结果和描述如表9.28所示:

9.28  fn:substring函数

参数

描述

string

源字符串。其类型必须为String类型

beginIndex

指定起始下标(值从0开始)。其类型必须为int类型

endIndex

指定结束下标(值从0开始)。其类型必须为int类型

返回结果

返回一个String类型的值

下面看一个示例。

${fn:substring("ABC","1","2")}<br>

截取结果为“B”。

原文在:http://www.360doc.com/showWeb/0/0/311738.aspx
http://www.jmfq.cn/news/5116771.html

相关文章:

  • 网站后台编辑器内容不显示/外贸seo优化
  • 简洁的网站设计/购买模板建站
  • iis网站属性怎么打开/合肥关键词排名推广
  • web版wordpress/seo搜索引擎优化排名
  • 设计网站建站/关键词挖掘站网
  • 没网站可以做seo吗/网站推广投放
  • 惠阳区建设局网站/上海关键词推广公司
  • 珠海pc网站建设/怎么在百度发布免费广告
  • 营销型网站建设的费用报价单/seo推广 课程
  • 广州专业网站建设报价/seo销售代表招聘
  • 网站制作广告/建立网站费用大概需要多少钱
  • 做网站页面的框架/零基础能做网络推广吗
  • 福田做商城网站建设找哪家公司好/广州seo工程师
  • 家电网站设计方案/网店如何做推广
  • 上海公司网站建设以子/seo推广主要做什么的
  • 图书馆网络规划与设计/黑河seo
  • 百度网站官方认证怎么做/域名申请的流程
  • 珠海响应式网站建设/网站权重查询
  • 网站进入沙盒的表现/长沙网站制作关键词推广
  • 阿里云上能建设自己的企业网站/优化百度涨
  • 毕业设计做课程网站好/免费推广平台哪些比较好
  • 无锡鸿源建设集团有限公司网站/重庆百度关键词推广
  • 政府网站建设赏析/企业网站建设制作
  • 鲲鹏建设集团有限公司网站/郴州网站seo外包
  • 房地产培训网站建设/优化网站性能
  • 发布app需要什么条件/seo的基本内容
  • 繁体网站怎么做/seo免费推广
  • 简易网站制作软件/深圳做网站公司
  • 网站图片上的水印怎么做/游戏推广员拉人技巧
  • 国家安全部门是干什么的/网站优化排名资源