码迷,mamicode.com
首页 > Web开发 > 详细

jstl标签

时间:2016-05-31 07:41:45      阅读:210      评论:0      收藏:0      [点我收藏+]

标签:

<%@ 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>

 

jstl标签

标签:

原文地址:http://www.cnblogs.com/lzhp/p/5544590.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!