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

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

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

    愚僧

    贏與輸的差別通常是--不放棄

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

    2013年2月26日 #



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

    1. 定義tld標簽描述文件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 對應 -->
        <uri>http://www.customtag.com/custom_tag</uri>
        <!-- 定義一個標簽 -->
        <tag>
            <!-- 標簽的名稱 -->
            <name>date</name>
            <!-- 標簽類 -->
            <tag-class>com.customtag.tags.DateTag</tag-class>
            <!-- 標簽體 -->
            <body-content>empty</body-content>
            <attribute>
                <!-- 屬性名稱 -->
                <name>format</name>
                <!-- 是否必選 true:必選 -->
                <required>false</required>
                <!-- 是否允許使用表達式(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. 使用自定義標簽
    <%@ 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>
            自定義標簽測試 : 
            <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>

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


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






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


    用于執行控制臺命令

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

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

    用于忽略掉錯誤信息

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


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

    serializeArray : 序列化表格元素 (類似 '.serialize()' 方法) 返回 JSON 數據結構數據
    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)編輯 收藏


    Class.forName("binary name");
    加載并對類變量進行初始化
    等價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多產生一個obj對象

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


    escape/unescape : 不能對uri編碼, 會把 / ? @ 進行編碼
    encodeURIComponet/decodeURIComponent : 對URI參數編碼, 會把 / 進行編碼
    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 統一資源標識
    url : Uniform Resource Locator   統一資源定位

    異:
    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 閱讀(129) | 評論 (0)編輯 收藏

    //將jQuery的$函數改名為$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 ?>

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

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

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


    提供一套標準, 實現web服務器之間信息通訊, 接口調用
    posted @ 2013-02-26 09:44 ywm 閱讀(112) | 評論 (0)編輯 收藏


    語法:
    (select ...)
    union [all] | intersect | minus
    (select ...)

    union              并集,排重, 排序
    union all          并集, 排重
    intersect         交集
    minus             差

    from : http://1632004.blog.163.com/blog/static/29991497201282653334529/
    posted @ 2013-02-26 09:33 ywm 閱讀(507) | 評論 (0)編輯 收藏

    主站蜘蛛池模板: 国产精品久久亚洲不卡动漫| 日韩精品一区二区亚洲AV观看| 久久久久亚洲国产| 91成人免费在线视频| 亚洲精品午夜久久久伊人| 99视频在线精品免费| 精品亚洲A∨无码一区二区三区| 久久香蕉国产线看免费| 91亚洲国产成人久久精品网站| a拍拍男女免费看全片| 亚洲人成免费电影| 中文字幕亚洲一区| www在线观看免费视频| 亚洲亚洲人成综合网络| 免费精品无码AV片在线观看| 亚洲精品国产肉丝袜久久| 免费看成人AA片无码视频羞羞网| 亚洲色大成网站www尤物| 国产乱子伦精品免费女| 久久久久久av无码免费看大片| 亚洲AV第一页国产精品| 18国产精品白浆在线观看免费| WWW亚洲色大成网络.COM| 国产亚洲美女精品久久久2020| 亚洲一区二区在线免费观看| 亚洲免费福利视频| 亚洲?V乱码久久精品蜜桃| 青青操在线免费观看| 亚洲国产成人在线视频| 免费a级毛片无码av| 久久国产乱子免费精品| 亚洲色欲色欱wwW在线| 亚洲综合国产一区二区三区| 亚洲视频在线免费看| 老司机午夜免费视频| 亚洲成年人在线观看| 日本特黄特黄刺激大片免费| 免费毛片在线看不用播放器| 亚洲午夜无码久久久久软件| 国产亚洲精品福利在线无卡一| 999久久久免费精品国产|