JSP标准标签库(JSTL)

    xiaoxiao2025-02-05  57

    简介

    JSTL(Java ServerPages Standard Tab Library)  JSP标准标签库

    JSTL前缀URL范例核心标签库chttp://java.sun.com/jsp/jstl/core<c:out>I18N格式标签库fmthttp://java.sun.com/jsp/jstl/xml<fmt:formatDate>SQL标签库sqlhttp://java.sun.com/jsp/jstl/sql<sql:query>XML标签库xmlhttp://java.sun.com/jsp/jstl/fmt<x:forBach>函数标签库fnhttp://java.sun.com/jsp/jstl/function<fn:sqlit>

     

    核心标签库

    核心标签库名称功能<c:out>   <c:set>   <c:remove>    <c:catch>表达式操作<c:if>    <c:choose>    <c:when>    <c:otherwise>流程控制操作<c:forEach>    <c:forTokens>迭代操作<c:param>    <c:import>    <c:redirect>    <c:url>URL操作

    out  if choose when otherwise

    <jsp:useBean id="people" class="cn.qyc.Javab.JavaBeanxx" /> <jsp:setProperty property="use" name="people" param="name" /> <jsp:setProperty property="password" name="people" param="password" /> <c:if test="${param.name=='qyc'}"> <jsp:getProperty property="use" name="people" /> <jsp:getProperty property="password" name="people" /> </c:if> <c:choose> <c:when test="${empty param.password }"> 没输入密码! </c:when> <c:when test="${param.password=='123456'}"> 密码:123456 </c:when> <c:when test="${param.password=='456789'}"> 密码:456789 <c:out value="密码:456789${param.name }"></c:out> </c:when> <c:when test="${param.password=='qycssg!'}"> </c:when> <c:otherwise> 密码: <c:out value="${param.password}" escapeXml="false" /> <c:redirect url="http://www.hxci.com.cn/"></c:redirect> </c:otherwise> </c:choose>

    forEach

    <% ArrayList<String> cart = new ArrayList<String>(); String aString = "qyc"; cart.add(aString); cart.add("asd"); cart.add("zxc"); %> <c:forEach var="names" items="<%=cart %>"> ${names} </c:forEach>

     

    最新回复(0)