• jstl标签


    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    
    <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>jstl练习</title>
    
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
        <link rel="stylesheet" type="text/css" href="styles.css">
        -->
    
    </head>
    
    <body>
        This is my JSP page.
        <br>
        <h6>下面是out测试</h6>
        <c:out value="out"></c:out>
        <h6>下面是set测试</h6>
        <%
            request.setAttribute("out", "hello");
        %>
        <c:set var="username" value="test"></c:set>
        <c:out value="${username }" />
        <h6>下面是curl测试</h6>
        <a
            href="<c:url value='index.jsp'>
          <c:param name='username' value='战三'/> </c:url>">index
        </a>
    
        <h6>下面是if测试</h6>
        <c:set var="password" value="12345"></c:set>
        <c:if test="${not empty password}">
            <c:out value="${password}"></c:out>
        </c:if>
    
        <h6>下面是choose测试</h6>
        <c:choose>
            <c:when test="${not empty param.name}">测试空</c:when>
            <c:otherwise>不为空</c:otherwise>
        </c:choose>
        <h6>下面是foreach测试</h6>
        <c:forEach var="i" begin="1" end="10">
            ${i}
        </c:forEach>
        <br />
        <%
            String[] array = { "1", "2" };
            request.setAttribute("array", array);
        %>
    
        <c:forEach items="${array}" var="item">
             ${item}
        </c:forEach>
    
    <h6>下面是fmt测试</h6>
     
    <c:out value="记得加fmt库"/>
    <%
        Date date=new Date();
        request.setAttribute("date", date);
     %>
     当前时间为:
    <fmt:formatDate value="${date}" pattern="yyyy-MM-dd hh:mm:ss"/>
    </body>
    </html>
  • 相关阅读:
    测试必备基础知识总结
    初级测试工程师与高级测试工程师的区别
    调试Java程序持续占cpu问题
    Spring Struts Hibernate trouble shooting | 一些问题的记载
    MySQL 性能调优之查询优化
    Tomcat性能调优 | Tomcat Performance Tuning
    Tomcat配置、管理和问题解决 | Tomcat Configuration, Manangement and Trouble Shooting
    SWT Browser & XULRunner
    Windows应用安装制作工具调查报告
    CentOS Configuration | CentOS配置
  • 原文地址:https://www.cnblogs.com/lzhp/p/5544590.html
Copyright © 2020-2023  润新知