• jstl标签具体解释


    一般用途的标签

    <%@ page language="java" pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    
    <title>一般用途的标签</title>
    
    
    </head>
    
    <body>
    	<c:out value="${username }" default="wangzs"></c:out>
    	<br />
    	<c:set var="user" value="wangmm"></c:set>
    	${user }
    	<br />
    	<c:remove var="user" />
    	user的值: ${user }
    	<br />
    	<c:catch var="异常的名字">
    	</c:catch>
    	<br>
    </body>
    </html>
    

    条件标签、格式化标签

    <%@page import="java.util.*"%>
    <%@page import="com.wzs.bean.Person"%>
    <%@ page language="java" pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    
    <title>条件标签、格式化标签</title>
    <%
    	request.setAttribute("name", "wangzs");
    	Map map = new HashMap();
    	map.put("1", "a");
    	map.put("2", "b");
    	map.put("3", "c");
    	map.put("4", "d");
    	request.setAttribute("map", map);
    
    	Person person1 = new Person(1, "wangzs");
    	Person person2 = new Person(2, "wangmm");
    	List list = new ArrayList();
    	list.add(person1);
    	list.add(person2);
    	request.setAttribute("list", list);
    %>
    
    </head>
    
    <body>
    	------条件标签-------
    	<c:if test="${name=='wangzs' }" var="result">
    		名字叫wangzs | ${result }
    	</c:if>
    	<br />
    	<c:choose>
    		<c:when test="${name == 'admin' }">欢迎admin</c:when>
    		<c:when test="${name == 'wangzs' }">欢迎wangzs</c:when>
    		<c:otherwise>欢迎用户哦!

    </c:otherwise> </c:choose> <br /> <c:forEach var="temp" items="${map }"> ${temp.key }|${temp.value }<br /> </c:forEach> <br /> <c:forEach var="person" items="${list }"> 用户id:${person.id } | username:${person.name }<br /> </c:forEach> <br /> <c:forEach var="i" begin="5" end="15" step="2"> ${i } : </c:forEach> <br /> <c:forTokens items="wang#zheng#12#ab#中国#美国#999" delims="#" var="temp"> ${temp } | </c:forTokens> <br /> ------格式化标签------- <!-- 格式化数字:整数最少2位。小数最少1位最多2位,每三个数字一组用,分开 --> <br /> <fmt:formatNumber value="123456.7891" pattern="#,#00.0#"></fmt:formatNumber> <br /> <!-- 已经格式化的字符串转换为数字 --> <fmt:parseNumber value="123,456.7891" type="number"></fmt:parseNumber> <br /> <fmt:formatDate value="<%=new java.util.Date() %>" type="date" /> | <fmt:formatDate value="<%=new java.util.Date() %>" type="time" /> | <fmt:formatDate value="<%=new java.util.Date() %>" type="both" /> | <br /> <fmt:parseDate value="2014-5-18 23:02:25" type="both"></fmt:parseDate> </body> </html>


    functions标签库

    <%@ page language="java" pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    
    <title>functions标签库</title>
    
    
    </head>
    
    <body>
    	Functions标签库是在JSTL中定义的标准的el函数集
    	<br /> ${fn:contains("WANGzsABCdefg","wangzs") }
    	<br /> ${fn:containsIgnoreCase("WANGzsABCdefg","wangzs") }
    	<br /> ${fn:startsWith("WANGzsABCdefg","王") }
    	<br /> ${fn:endsWith("WANGzsABCdefg","fg") }
    	<br /> WANGzsABCdefg中zs在: ${fn:indexOf("WANGzsABCdefg","zs") }
    	<br /> ${fn:replace("WANGzsABCdefg","WANGzs","XXXX") }
    	<br />WANGzsABCdefg,3和6之间:${fn:substring("WANGzsABCdefg",3,6) }
    	<br />WANGzsABCdefg中Cd之前的字符:${fn:substringBefore("WANGzsABCdefg","Cd") }
    	<br />WANGzsABCdefg中zsA之后的字符:${fn:substringAfter("WANGzsABCdefg","zsA") }
    	<br />
    	<c:set var="welcom" value="${fn:split('welcom-to-bei-jing-!','-') }"></c:set>
    	<c:forEach var="token" items="${welcom }">
    		${token }
    	</c:forEach>
    	<br />fn:join使用方法: ${fn:join(welcom,"#") }
    	<br />
    	<c:forEach var="token" items="${welcom }">
    		${token }
    	</c:forEach>
    	<br />${fn:toLowerCase("WANGzsABCdefg") }
    	<br />${fn:toUpperCase("WANGzsABCdefg") }
    	<br />去掉字符串前后的字符:${fn:trim(" wangzs ") }ok
    	<br />${fn:length("wangzs") } | ${fn:length("1236") }
    </body>
    </html>
    


  • 相关阅读:
    Flask特殊装饰器
    flask中的Response、Request、Session、装饰器、实例化参数、蓝图、
    QC的安装和配置
    测试用例设计方法-因果图(鱼骨图)
    测试用例设计方法-流程分析法(场景法)
    测试用例设计方法-状态迁移
    测试用例设计方法-正交实验
    测试用例设计方法-判定表
    测试用例设计方法-边界值
    测试用例设计方法-等价类划分
  • 原文地址:https://www.cnblogs.com/wgwyanfs/p/6992397.html
Copyright © 2020-2023  润新知