<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年3月4日 #



    步驟:
    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>
        <!-- 定義一個(gè)標(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時(shí)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時(shí)18分29秒
    posted @ 2013-03-04 16:35 ywm 閱讀(119) | 評論 (0)編輯 收藏

    2013年3月1日 #


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






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


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

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

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

    用于忽略掉錯(cuò)誤信息

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


    serialize : 序列表表格內(nèi)容為字符串, 返回的是一個(gè)字符串
    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 閱讀(640) | 評論 (2)編輯 收藏

    2013年2月27日 #


    Class.forName("binary name");
    加載并對類變量進(jìn)行初始化
    等價(jià)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時(shí)初始化
    初始化時(shí)會(huì)比forName多產(chǎn)生一個(gè)obj對象

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


    escape/unescape : 不能對uri編碼, 會(huì)把 / ? @ 進(jìn)行編碼
    encodeURIComponet/decodeURIComponent : 對URI參數(shù)編碼, 會(huì)把 / 進(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 閱讀(118) | 評論 (0)編輯 收藏


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

    異:
    url是uri的一個(gè)子集
    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 閱讀(129) | 評論 (0)編輯 收藏

    2013年2月26日 #

    //將jQuery的$函數(shù)改名為$jq
    var $jq = jQuery.noConflict();
    //$('d1').innerHTML = 'hello  jQuery';
    $jq('#d1').html('hello  jQuery');
    posted @ 2013-02-26 10:38 ywm 閱讀(126) | 評論 (0)編輯 收藏


    語法:
    1 <?php
    2 define("CONSTANT", "Hello world.");
    3 echo CONSTANT// 輸出 "Hello world."
    4 ?>

    規(guī)則:
    • 常量前面沒有美元符號(hào)($
    • 常量只能用define()函數(shù)定義,而不能通過賦值語句
    • 常量一旦定義就不能被重新定義或者取消定義
    • 常量的值只能是標(biāo)量(integer,float,string,boolean)

    魔術(shù)常量:
    名稱 說明
    __LINE__ 文件中的當(dāng)前行號(hào)。
    __FILE__ 文件的完成路徑和文件名。
    __FUNCTION__ 函數(shù)名稱。(這是 PHP 4.3.0 新加的。)
    __CLASS__ 類的名稱。(這是 PHP 4.3.0 新加的。)

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

    僅列出標(biāo)題  下一頁
    主站蜘蛛池模板: 亚洲日本乱码一区二区在线二产线| 亚洲爆乳精品无码一区二区| www.999精品视频观看免费| 国产亚洲Av综合人人澡精品| 亚洲精品高清无码视频| 无码免费午夜福利片在线| 国产vA免费精品高清在线观看| 亚洲成人高清在线观看| 国产男女猛烈无遮挡免费视频 | 免费日本一区二区| 中文日韩亚洲欧美制服| 亚洲精品乱码久久久久久蜜桃不卡| 国产电影午夜成年免费视频| 一级毛片免费在线播放| 67194在线午夜亚洲| 亚洲精品国产精品乱码在线观看| 最近2019中文免费字幕| 久久大香香蕉国产免费网站| 在线看亚洲十八禁网站| 亚洲国产精品久久人人爱| 亚洲中文字幕无码一区| 免费毛片在线视频| 亚洲欧洲精品久久| 亚洲色欲久久久久综合网| 国产美女在线精品免费观看| 四虎影视在线影院在线观看免费视频| 亚洲成a∧人片在线观看无码| 久久99亚洲网美利坚合众国| 亚洲精品国产日韩无码AV永久免费网| 67194熟妇在线永久免费观看| 免费精品久久天干天干| 亚洲AV第一页国产精品| 亚洲AⅤ视频一区二区三区| 国产精品美女午夜爽爽爽免费| 免费无码又爽又刺激网站| 国产亚洲美女精品久久久久| 国产精品亚洲精品观看不卡| 18亚洲男同志videos网站| 亚洲第一极品精品无码久久| 精品国产香蕉伊思人在线在线亚洲一区二区 | 亚洲av无码专区青青草原|