zoukankan      html  css  js  c++  java
  • JSTL标签

    <html>
    <body>
    <h2>Hello World!</h2>
    </body>
    </html>
    
    
    <%@ page language="java" contentType="text/html; charset=UTF-8"
             pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <html>
    <head>
        <title>c:if 标签实例</title>
    </head>
    <body>
    <c:set var="salary" scope="session" value="4000"/>
    <p>你的工资是 : <c:out value="${salary}"/></p>
    <c:remove var="salary"/>
    <p>删除 salary 变量后的值: <c:out value="${salary}"/></p>
    
    <c:import var="data" url="http://www.baidu.com"/>
    <!--<c:out value="${data}"/>  -->
    
    <c:choose>
    
        <c:when test="${salary <= 0}">
            太惨了。<br>
        </c:when>
        <c:when test="${salary > 1000}">
            不错的薪水啊 <br>
        </c:when>
        <c:otherwise>
          好好工作 <br>
        </c:otherwise>
    </c:choose>
    
    <c:forEach var="i" begin="1" end="5">
        <c:choose>
            <c:when test="${i eq '1'}">
                <c:out value="对应的值是1"></c:out> <br>
            </c:when>
            <c:when test="${i eq '2'}">
                <c:out value="对应的值是2"></c:out><br>
            </c:when>
            <c:when test="${i eq '3'}">
                <c:out value="对应的值是3"></c:out><br>
            </c:when>
            <c:when test="${i eq '4'}">
                <c:out value="对应的值是4"></c:out><br>
            </c:when>
            <c:when test="${i eq '5'}">
                <c:out value="对应的值是5"></c:out><br>
            </c:when>
           <c:otherwise>
               <c:out value="无对应的值"></c:out>
           </c:otherwise>
        </c:choose>
    
    </c:forEach>


    <c:forEach var="i" begin="1" end="5">
    
        <c:if test="${i<3}">
            <c:out value="对应的值为${i}"></c:out>
        </c:if>
    </c:forEach>
    
    对应的值为1 对应的值为2
    
    
    

    <c:forTokens items="baidu,google,taobao" delims="," var="name"> <c:out value="${name}"></c:out> </c:forTokens> <c:url var="myURL" value="index.jsp"> <c:param name="name" value="Runoob"/> <c:param name="url" value="www.runoob.com"/> </c:url> <a href="/<c:out value="${myURL}"/>"> 使用 &lt;c:param&gt; 为指定URL发送两个参数。</a> <c:url var="testurl" value="index.jsp"> <c:param name="name" value="zhangsan"/> <c:param name="age" value="23"/> </c:url> <!-- http://localhost:8081/index.jsp?name=zhangsan&age=23--> <a href="/<c:out value="${testurl}"/>"> 使用 &lt;c:param&gt; 为指定URL发送两个参数。</a> <!-- --> <a href="<c:url value="http://www.baidu.com" />"> 点击跳转到百度首页 </a> <a href="<c:url value="http://www.runoob.com"/>"> 这个链接通过 &lt;c:url&gt; 标签生成。 </a> </body> </html>
    <%@ page language="java" contentType="text/html; charset=UTF-8"
             pageEncoding="UTF-8"%>
    <%@ page import="java.io.*,java.util.*" %>
    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">
        <title>菜鸟教程(runoob.com)</title>
    </head>
    <body>
    <h1>使用 GET 方法读取数据</h1>
    <ul>
        <li><p><b>站点名:</b>
    
            <%= request.getParameter("name")%>
        </p></li>
        <li><p><b>网址:</b>
            <%= request.getParameter("url")%>
        </p></li>
    </ul>
    
    <form action="index.jsp" method="GET">
        站点名: <input type="text" name="name">
        <br />
        网址: <input type="text" name="url" />
        <input type="submit" value="提交" />
    </form>
    
    
    <html>
    <head>
        <title>自动刷新实例</title>
    </head>
    <body>
    
    <h2>自动刷新实</h2>
    <%
        // 设置每隔5秒刷新一次
        response.setIntHeader("Refresh", 1);
        // 获取当前时间
        Calendar calendar = new GregorianCalendar();
        String am_pm;
        int hour = calendar.get(Calendar.HOUR);
        int minute = calendar.get(Calendar.MINUTE);
        int second = calendar.get(Calendar.SECOND);
        if(calendar.get(Calendar.AM_PM) == 0)
            am_pm = "AM";
        else
            am_pm = "PM";
        String CT = hour+":"+ minute +":"+ second +" "+ am_pm;
        out.println("当前时间为: " + CT + "
    ");
    %>
    
    
    <%
        Integer hitsCount =
                (Integer)application.getAttribute("hitCounter");
        if( hitsCount ==null || hitsCount == 0 ){
           /* 第一次访问 */
            out.println("欢迎访问菜鸟教程!");
            hitsCount = 1;
        }else{
           /* 返回访问值 */
            out.println("欢迎再次访问菜鸟教程!");
            hitsCount += 1;
        }
        application.setAttribute("hitCounter", hitsCount);
    %>
    
    <p>页面访问量为: <%= hitsCount%></p>
    
    </body>
    </html>
    
    
    </body>
    </html>
  • 相关阅读:
    用成员函数指针作为Callback
    在ubuntu上编译gcc会到的问题及解决方法
    异步
    棋牌游戏服务器架构: 详细设计(二) 应用层设计
    elementUI eltable添加序号列
    vue 父子组件的相互调用
    所谓编程的哲学艺术
    亲爱的百度,您带着bug翩翩走来……呃
    std::vector<point>对距离固定点的距离排序
    升级ubuntu11出现grub错误
  • 原文地址:https://www.cnblogs.com/wangchuanfu/p/7814418.html
Copyright © 2011-2022 走看看