<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    愚僧

    贏與輸?shù)牟顒e通常是--不放棄

    BlogJava 首頁 新隨筆 聯(lián)系 聚合 管理
      23 Posts :: 0 Stories :: 2 Comments :: 0 Trackbacks

    2013年2月27日 #



    步驟:
    1. 定義tld標(biāo)簽描述文件
    2. 新建class繼承SimpleTagSupport或者BodyTagSupport
    3. taglib命令聲明
    4. 使用自定義標(biāo)簽

    1. 定義tld標(biāo)簽描述文件custom_tag.tld
    <?xml version="1.0" encoding="UTF-8"?>
    <taglib xmlns="http://java.sun.com/xml/ns/j2ee"
        xmlns:xsi
    ="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation
    ="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
        version
    ="2.0">
        <description>JSTL 1.1 core library</description>
        <display-name>JSTL core</display-name>
        <tlib-version>1.1</tlib-version>
        <short-name>ct</short-name>
        <!-- 與 taglib 的 uri 對應(yīng) -->
        <uri>http://www.customtag.com/custom_tag</uri>
        <!-- 定義一個標(biāo)簽 -->
        <tag>
            <!-- 標(biāo)簽的名稱 -->
            <name>date</name>
            <!-- 標(biāo)簽類 -->
            <tag-class>com.customtag.tags.DateTag</tag-class>
            <!-- 標(biāo)簽體 -->
            <body-content>empty</body-content>
            <attribute>
                <!-- 屬性名稱 -->
                <name>format</name>
                <!-- 是否必選 true:必選 -->
                <required>false</required>
                <!-- 是否允許使用表達(dá)式(EL), false:不能使用 -->
                <rtexprvalue>false</rtexprvalue>
            </attribute>
            <attribute>
                <name>value</name>
                <required>false</required>
                <rtexprvalue>true</rtexprvalue>
            </attribute>
        </tag>
    </taglib>
    注:
    可參考jstl-[version].jar中META-INF下的c.tld文件

    2. 新建DateTag繼承SimpleTagSupport或者BodyTagSupport
    package com.customtag.tags;

    import java.io.IOException;
    import java.text.SimpleDateFormat;
    import java.util.Date;

    import javax.servlet.jsp.JspException;
    import javax.servlet.jsp.JspWriter;
    import javax.servlet.jsp.PageContext;
    import javax.servlet.jsp.tagext.SimpleTagSupport;

    public class DateTag extends SimpleTagSupport {
        
        @Override
        public void doTag() throws JspException, IOException {
            SimpleDateFormat sdf = new SimpleDateFormat(format);
            PageContext pc = (PageContext) getJspContext();
            JspWriter out = pc.getOut();
            try{
                if(null != this.getValue()){
                    out.print(sdf.format(new Date(this.getValue())));
                }else{
                    out.print(sdf.format(new Date()));
                }
            }catch(IOException e){
                throw e;
            }catch(Exception e){
                out.print("");
            }
        }
        
        private String format="yyyy-MM-dd HH:mm:ss";
        
        private Long value = null;
        
        public String getFormat() {
            return format;
        }

        public void setFormat(String format) {
            this.format = format;
        }

        public Long getValue() {
            return value;
        }

        public void setValue(Long value) {
            this.value = value;
        }
        
    }

    3. taglib命令聲明
    <%@taglib prefix="ct" uri="http://www.customtag.com/custom_tag"%>

    4. 使用自定義標(biāo)簽
    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <%
        
    String path = request.getContextPath();
        
    String basePath = request.getScheme() + "://"
                
    + request.getServerName() + ":" + request.getServerPort()
                
    + path + "/";
    %>
    <%@taglib prefix="ct" uri="http://www.customtag.com/custom_tag"%>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
        <head>
            <base href="<%=basePath%>">

            <title>My JSP 'index.jsp' starting page</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>
            自定義標(biāo)簽測試 : 
            <br>
            <ct:date/><br/>
            <ct:date format="MM/dd/yyyy"/><br/>
            <ct:date format="yyyy年MM月dd日 HH時mm分ss秒" value="<%=new Date().getTime() %>"/><br/>
        </body>
    </html>

    [運(yùn)行結(jié)果]
    自定義標(biāo)簽測試:
    2013-03-04 16:18:29
    03/04/2013
    2013年03月04日 16時18分29秒
    posted @ 2013-03-04 16:35 ywm 閱讀(127) | 評論 (0)編輯 收藏


    以下情況被認(rèn)為 false :
    • boolean類型的FALSE
    • int類型的0
    • 浮點類型的0.0
    • 字符串"" 或者 "0"
    • 空的數(shù)組
    • 空的對象null
    其他情況都認(rèn)為是true






    posted @ 2013-03-01 17:51 ywm 閱讀(135) | 評論 (0)編輯 收藏


    用于執(zhí)行控制臺命令

    $output = `ls -al`;
    echo "<pre>$output</pre>";

    有對平臺依賴性, 降低了php跨平臺能力
    posted @ 2013-03-01 16:30 ywm 閱讀(102) | 評論 (0)編輯 收藏

    用于忽略掉錯誤信息

    <?php
    //忽略包含文件時產(chǎn)生的錯誤
    @include("inc.php");
    //忽略連接mysql數(shù)據(jù)庫出錯產(chǎn)生的錯誤信息
    $conn = @mysql_connect("localhost","username","password");
    //忽略打開文件產(chǎn)生的錯誤信息
    $fp  = @fopen("user.xml","w");
    function test(){
    return 10;
    }
    //忽略調(diào)用函數(shù)失敗產(chǎn)生的錯誤信息
    $number = @test();
    ?>
    posted @ 2013-03-01 16:25 ywm 閱讀(112) | 評論 (0)編輯 收藏


    serialize : 序列表表格內(nèi)容為字符串, 返回的是一個字符串
    var serializeStr = $("form").serialize();
    result : username=forrest&passwd=1234&gender=0&interest=swimming&interest=running&interest=readBook

    serializeArray : 序列化表格元素 (類似 '.serialize()' 方法) 返回 JSON 數(shù)據(jù)結(jié)構(gòu)數(shù)據(jù)
    var fields = $("select, :radio").serializeArray();
    jQuery.each( fields, function(i, field){
      $("#results").append(field.name + "=" +field.value + "; ");
    });
    result : username=forrest; passwd=1234; gender=0; interest=swimming; interest=running; interest=readBook; 
    posted @ 2013-03-01 15:42 ywm 閱讀(647) | 評論 (2)編輯 收藏


    Class.forName("binary name");
    加載并對類變量進(jìn)行初始化
    等價cl.loadClass("binary name").newInstance();

    ClassLoader.loadClass("binary name");
    ClassLoader cl = this.getClass().getClassLoader();
    Class c = cl.loadClass("binary name");
    Object obj = c.newInstance();
    在newInstance時初始化
    初始化時會比forName多產(chǎn)生一個obj對象

    From : http://waryist.iteye.com/blog/131983
    posted @ 2013-02-27 15:57 ywm 閱讀(130) | 評論 (0)編輯 收藏


    escape/unescape : 不能對uri編碼, 會把 / ? @ 進(jìn)行編碼
    encodeURIComponet/decodeURIComponent : 對URI參數(shù)編碼, 會把 / 進(jìn)行編碼
    encodeURI/decodeURI : 對URI編碼

    From : http://blog.163.com/free_for_all/blog/static/6871811201192441843281/
    From : http://www.cnblogs.com/qiantuwuliang/archive/2009/07/19/1526687.html
    posted @ 2013-02-27 11:44 ywm 閱讀(123) | 評論 (0)編輯 收藏


    uri : Uniform Resource Identifier 統(tǒng)一資源標(biāo)識
    url : Uniform Resource Locator   統(tǒng)一資源定位

    異:
    url是uri的一個子集
    url可以用相對路徑表示, url 只能用絕對路徑表示

    同:
    url,uri 都能定位唯一資源

    注:
    [scheme:][//authority][path][?query][#fragment]
    authority為[user-info@]host[:port]
    相對路徑和絕對路徑看是否使用"scheme:"開頭

    From : http://www.cnblogs.com/gaojing/archive/2012/02/04/2413626.html
    From : http://rebecca.iteye.com/blog/234724


    posted @ 2013-02-27 10:59 ywm 閱讀(134) | 評論 (0)編輯 收藏

    主站蜘蛛池模板: 亚洲精品亚洲人成在线观看下载 | 亚洲AV无码国产精品色| 亚洲av福利无码无一区二区| 亚洲Av熟妇高潮30p| 免费视频一区二区| 99久热只有精品视频免费看| 成年女人午夜毛片免费看| 免费大黄网站在线看| 亚洲国产精品无码久久久蜜芽| 亚洲国产精品久久久久婷婷软件 | 亚洲精品无码午夜福利中文字幕 | h视频免费高清在线观看| 怡红院免费的全部视频| 国产四虎免费精品视频| 亚洲精品国产精品乱码不卡| 一级美国片免费看| 免费电影在线观看网站| 亚洲精品无码久久一线| 久久久免费的精品| 亚洲精品国产精品乱码不卡| 免费人成激情视频在线观看冫| 国产美女做a免费视频软件| 亚洲精品美女久久久久9999| 麻豆一区二区三区蜜桃免费| 免费观看AV片在线播放| 亚洲人成网址在线观看| 男女免费观看在线爽爽爽视频 | 亚洲人成影院在线观看| 亚洲欧洲日韩极速播放| 最近免费mv在线观看动漫| 亚洲视频在线观看不卡| 久久国产精品2020免费m3u8| 中文字幕不卡亚洲 | 国产日韩在线视频免费播放| 国产精品高清全国免费观看| 一级一黄在线观看视频免费| 亚洲精品美女在线观看播放| av无码东京热亚洲男人的天堂| 国产AV无码专区亚洲AV麻豆丫| 4hu四虎最新免费地址| 自拍偷自拍亚洲精品播放|