您的位置:首页 > 运维架构

监控VMware ESX 虚拟机的好工具vcenter operations manager

2013-02-05 17:35 447 查看
JSTL: Jsp Standard Tag Libraries
 
JSTL is a collection of custom tags libraries. It provides common functionality that many web applications need. JSTL provides support for presentation logic (core), formatting (format), XML support (XML) and database access (SQL).
 
Expression Language (EL)
One of the limitations of JSP1.2 and earlier is that it relies heavily on Java scriptlets and Java expressions, which do not fit in the scripting and templating model that JSP espouses. With EL, you can retrieve and manipulate values in JSP scopes (session, request, page, application), headers, and parameters.
${对象.属性}  或 ${对象[属性]}ç标准形式
 
 
<c:out value="${tagInfo.name}" default="default" escapeXml="false"/>
Out标签: value 是要输出的对象,default是当要输出的对象为null的时候,默认的输出。若对象中包含xml敏感字符,如: <,>,/的时候,escapeXml若设为false,生成的html页面就认为这些字符是xml标签,不会将其直接显示为文本形式。
 
 
<c:set var="myVar" value="${tagInfo.name}" scope="session"/>
Set标签:将定义一个在指定范围内(scope)的变量var,其值就是value。若scope不指定,则认为是page。
<c:set target="${tagInfo}" property="pwd" value="999"/>
将可访问范围内的对象(target)的属性(property)设为某值(value)。这里注意一点,scope属性必须当var属性存在时才能有。
 
 
<c:if var="result" test="${tagInfo.sex eq 'M'}" scope="page">
       性别为男
</c:if>
If 标签用来做比较,判断真假的条件就是test, 并可把比较结果true or false存入一个变量var,并保存在某一范围scope,以供使用。
 
<c:if test="${result}">性别为男</c:if>
用刚才存放的变量,而不用针对同一比较反复写条件表达式。

     <c:choose>
       <c:when test="${result}">
           性别为男
       </c:when>
       <c:when test="${tagInfo.sex eq 'F'}">
           性别为女
       </c:when>
       <c:otherwise>
           中性人
       </c:otherwise>
    </c:choose>
Choose -> When -> Otherwise 是一套比较的流程。
相当于java的 if…else if….else
 
 
<c:url var="urlOfTome365"
    value=http://www.tom365.com/movie_2004/html/2852.html 外部URL
    scope="page"/>
定义一个在指定范围可用的变量
<c:url var="welcome"  value="Welcome.do"/> 内部URL
 
然后<c:redirect url="${urlOfTome365}" />
就可以重定向到指定的资源。
 

<c:remove var="myVar" scope="session" />
从指定范围移除名为”myVar”的对象。
 

<c:import var="importedResource" url="http://www.tom365.com" charEncoding="GB2312" scope="session"/>
Import标签可以引入外部资源,将其内容以文本(String)方式保存在var。
 

<c:forEach var="item" items="${tagInfo.careers}"
    begin="1" end="6" step="2">
       <c:out value="${item.id}" />
       <c:out value="${item.value}" />
    </c:forEach>
用于循环集合。 Items必须是一个集合,var是集合中的单个元素,对循环内可见。Begin表示从index为多少处开始这个循环,end表示结束的index。Step是步长,就是循环的间隔。
 

<c:forTokens var="item" items="${items}" delims=","
    begin="1" end="13" step="3">
forTokens与forEach用法一样,只是多了一个delimiter分隔符
 

<c:url var="welcome" value="Welcome.do">
       <c:param name="p1" value="111"/>
       <c:param name="p2" value="222"/>
       <c:param name="p3" value="333"/>
       <c:param name="p4" value="444"/>
       <c:param name="p5" value="555"/>
</c:url>
嵌在c:url标签内,c:param标签用来给url带上参数。生成的html代码:
Welcome.do?p1=111&p2=222&p3=333&p4=444&p5=555
 

<c:catch var="ex1">
    <c:out value="${tagInfo.name.mm}" />
</c:catch>
将可能出现exception的代码块置于<c:catch>。。。。。。</c:catch>,这样如果jsp运行期间出现的异常就会被捕获到var里面。
 

<fmt:formatNumber
value="${tagInfo.salary}" type="number" pattern="###,###.##"/>
对于数字的格式化。
 
<fmt:formatNumber value="${tagInfo.salary}" type="currency"/>
对于货币的格式化,自动获得服务器的locale信息。添加如:$,¥前缀。
 
<fmt:formatNumber value="${tagInfo.salary}" type="percent" />
对于百分比格式化,就是将值乘以100再加%进行输出显示。
 

<fmt:formatDate value="${dt}" type="both" pattern="dd/MM/yyyy HH:mm:ss"/>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: