escape(),encodeURI() vs encodeURIComponent() 這三種都拿來當做編碼用,但仍然有一些小差別,目前主要還是用encodeURI() & encodeURIComponent()比較好

編碼-

escape():
ISO的ASCII系統,只要不是0-9,a-z,A-Z的都會被編碼成16進位的Unicode.
不編碼的符號包括: @*/+
缺點: 遇到UTF8可能會出錯,
 
encodeURI():
用 encodeURI() 會比使用 escape() 轉換 URI 正確。
不編碼的符號包括: ~!@#$&*()=:/,;?+'
注意 : 不處理 單引號,&,等等....要注意 


encodeURIComponent() 
處理的符號比encode還要多,所有幾乎都可以處理掉!
不編碼的符號包括:~!*()'
注意: 也不處理單引號, 特別的是連"/"也處理掉,如果是要傳到Server的要看Server能不能夠處理

解碼-

escape() vs unescape()
encodeURI() vs decodeURI()
encodeURIComponent() vs decodeURIComponent() 

minglight 發表在 痞客邦 留言(0) 人氣()

MSDN Link : 

http://msdn.microsoft.com/en-us/library/ms524602(VS.85).aspx

minglight 發表在 痞客邦 留言(0) 人氣()

Step1. 複製Mail list from sendTo....to Notepad++
Will get a string like this
XX, XX X<xxx.xxxx@intel.com>
 
Step2. 操作Notepad++
在Notepad++按下 [Ctrl+F] ,在介面左下方選取用類型表式(E)
在尋找目標欄位中放入 >;[A-Za-z,'\s]+<
取代成  ;
會得到
xxx.xxxx.intel.com
去頭去尾之後就是Email List了

 

minglight 發表在 痞客邦 留言(0) 人氣()

如果你想要當mouse over時變更cursor, css中有一個屬性是cursor, 當使用此屬性時即可達到你想要的目的.
EX: <input name="acct" style="cursor:progress"/>

但如果你想要的效果是,類似處理中請稍候,其實道理一樣,只是cursor的範圍改成body即可
EX: 

<style>
document.body.style.cursor = "progress";
//處理事情 
document.body.style.cursor = "default";
  //....結果document.body不能work.....

所以只好用body下面多加一層DIV吧 

</style>
 
樣式列表

 


auto
crosshair
default
e-resize
help
move
n-resize
ne-resize
nw-resize
pointer
progress
s-resize
se-resize
sw-resize
text
w-resize
wait

minglight 發表在 痞客邦 留言(0) 人氣()

http://spservices.codeplex.com

minglight 發表在 痞客邦 留言(0) 人氣()

Variables

Parameter Value
HttpHost URL of the Web server.
Language LCID of the language used on the site, for example 1033 for an English-language site.
ImagesPath URL of the images path, in the context of the current Web site, for example: http://server/sites/test/_layouts/images/
HttpPath URL of the path to the appropriate owssvr.dll file in the context of the current Web site. For example, http://server/sites/test/_vti_bin/owssvr.dll?CS=109, where CS=109 means that the UTF-8 character set is used for all communication to owssvr.dll.
HttpVDir Root directory of the current subsite. For example, for the page http://server/sites/test/default.aspx, the value is http://server/sites/test/.
PageUrl The URL of the currently requested page. For example, http://server/sites/test/default.aspx.
Project The site-relative URL of the root folder of a list, if the current page request is in the context of a list. This is the name of the folder that contains all the files used in working with the list, for example, Lists/Announcements.
View {GUID}. If the Web Part is a view of a list, this is the view identifier.
ListProperty_TemplateUrl When the current page request is in the context of a list, and the list is a document library, this is the URL of the template document for this document library.
ListUrlDir_FALSE When the current page request is in the context of a list, this is the complete URL to the root folder of the list, for example, http://server/sites/test/Lists/Announcements.
ListUrlDir_TRUE When the current page request is in the context of a list, this is the site-relative URL of the root folder of the list. (This is the same as parameter Project).
URL_New, URL_NEW When the current page request is in the context of a list, this is the URL to the page for creating a new item in the list (newform).
URL_Edit, URL_EDIT When the current page request is in the context of a list, this is the URL to the page for editing an existing item in the list (editform).
URL_Display,URL_DISPLAY When the current page request is in the context of a list, this is the URL to the page containing the default vi

 

ddwrt:Functions

    AutoHyperLink
    AutoNewLine
    ConnEnclode
    Counter
    FieldFilterImageUrl
    FieldFilterOptions
    FieldPrefix
    FieldSortImageUrl
    FieldSortParameters
    FilterLink
    FormatDate
    FormatDateTime
    GenDisplayName
    GenFireConnection
    GenFireServerEvent
    GetFileExtension
    GetStringBeforeSeparator
    GetVar
    IfNew
    IsPrivilegedUser
    Limit
    ListProperty
    MapToAll
    MapToControl
    MapToIcon
    NameChanged
    PresenceEnabled
    SelectOptions
    SetVar
    ThreadStamp
    Today
    TodayIso
    UrlBaseName
    UrlDirName
    UrlEncode
    URLLookup
    UserLookup

參考聯結 :
http://msdn.microsoft.com/en-us/library/dd583143(v=office.11).aspx

 

 

minglight 發表在 痞客邦 留言(0) 人氣()

為了不誤導大家,把一些看完Source的進階心得寫在這兒

1. 把Map<Thread,value>放在ThreadLocal的缺點
    在某些情況下Thread不會重複使用. 例如Web環境,Container會產生一個新的Thread來處理Request-Response,因此如果ThreadLocal設計方式是ThreadLocal-簡介,將Map放在ThreadLocal中,你會發現這個Map越來越大,越來越大,要直到你重開Server才會重置 ( 以上純屬個人推論 XD )


2. ThreadLocal實際運作方式
    ThreadLocal並不會自己存放Map,而是把Map放到Thread裡面去!!
    Thread中會有一個ThreadLocalMap<ThreadLocal,Object> ,注意這邊的Key變成了ThreadLocal物件本身, 因此每個ThreadLocalMap都有可能會有以不同的ThreadLocal相對應的值.
    其實這種方式更直覺,每個Thread會有一個空間放一些客製的變數,而且好處是,當Thread掛掉之後,這個Map也會跟著Thread被GC掉.

3. ThreadLocal的API
    protected T initialValue() 
給繼承者使用, 預設回傳null, 當呼叫get()拿到null時會呼叫initialValue()將值擺進去.

    其他直覺的使用如下
     +get() : T 
     +set(T) : void     
     +remove(T) : void 

4. 使用ThreadLocal的時機
    我查了一下網路,有人說當你對一個bean/resource使用synchronized的時候,常常是寫法不易而且效能不彰(因為Thread都在排隊等放飯).因此ThreadLocal可以拿來取代synchronized
    這種說法是部分正確的. 其道理在於如果你今天只有一個飯鍋, 放飯的時間一定會拉很長,如果使用ThreadLocal, 當你需要吃的時候我直接給你一碗飯,這時候就不需要排隊了.
   
    ThreadLocal的觀念就是個人造業個人擔,不管你要對你的飯做什麼都不會影響到別人
    但是synchronized內的邏輯,因為是大家共用一個飯鍋,當輪到你盛飯的時候,如果你在飯鍋裡面加了滷肉,整鍋飯就會變成魯肉飯了.
    因此ThreadLocal可以取代synchronized的時機只有在於沒有人會對飯動手腳的時候才適用.
       
    可以把它當作requestScope的延伸
   
這個就不需要太多解釋了,因為跟request在同一個Thread裡面 


如果大家有什麼寫錯的地方也請不吝指教喔~

文章標籤

minglight 發表在 痞客邦 留言(0) 人氣()

前置觀念 - 必須了解Thread, Thread.currentThread()被呼叫的機制, call stack機制.

ThreadLocal的目的 : 把變數存在currentThread中, 讓每個執行中的Thread都有自己的一份Copy, 而且彼此之間不會互相影響.

實作概念 : 
public class ThreadLocalConcept{
private Map<Thread,Object> localMap = Collections.synchronizedMap(new HashMap<Thread,Object>());

public void set(Object obj){
this.localMap.put(Thread.currentThread(), obj);
}

public Object get(){
this.localMap.get(Thread.currentThread());
}


基本上就是這個localMap會放著各個Thread對應的變數, 因此在不同的Thread中呼叫到的Value都會是獨立的.

用途範例 : 在DAO中拿到Login User
     
一般來說Login User都是放在Session中, 但是平常我們使用的Service & DAO都會是Singleton, 是共用的, 因此不能夠將Login User放入
        
我們可以利用一個Request-Response是一個獨立Thread的特性, 搭配ThreadLocal將Login User存入各個Thread中,就可以拿到相對應的Login User了


Step1. 建立一個共用的Thread Local

public class LoginUserUtil{
public static ThreadLocal<User> local = new ThreadLocal<User>();

public static User getUser(){
return local.get();
}

public static void setUser(User user){ 
local.set(user);

step2. 在BaseAction/BaseServlet/BaseController內放入LoginUser

public class BaseAction extends ...{
public doBaseRequest(){
User user = this.getRequest().getSession().getAttribute("loginUser");
LoginUserUtil.set(user);
}
}

step3. 在DAO中拿出LoginUser - 完工!!

public class XXXDAOImpl extends ...{
public void updateData(Data data){
data.setUpdateUser(LoginUserUtil.get());
this.update(data);
}
}

 




 

文章標籤

minglight 發表在 痞客邦 留言(1) 人氣()

純粹分享學習心得,並不會有系統的介紹Javascript,我的JS經驗也很粗淺,如果有寫錯或是遺漏也請不吝指教
另外參考良葛格學習筆記就可以得到完整版本的教學了

1. null vs undefined vs not defined error

    null代表null物件
        除非手動assign一個參考為null,不然參考不會出現null值

    undefined有兩種情形
        a. 是一個參考的預設值,宣告一個變數而不assign時,其值就會是undefined (function的參數被呼叫時沒有被給值也算是這種情形)
        b. 呼叫物件不存在的屬性也會得到undefined值
    
    not defined error
        如果使用一個沒有宣告過的變數,就會得到錯誤(xx is not defined) -- 程式中斷

minglight 發表在 痞客邦 留言(0) 人氣()

1. 分別描述 TCP , IP , HTTP 的
    a.功能
        TCP : 保證檔案完整, 管port的2^16(1~1023官方用的)
        IP  : 保證送對地方, 管IP的
        HTTP : 請求與回應,在TCP&IP之上建立的

2. Request包括了 method, url, param(包含header)
   Respnose包括了 state ,content-type , 內容(HTML)
   
3.Html是 Response的一部分

4.Get&Post
  a.Get有字數限制
  b.Get可以被加入書簽(因為在URL後面),Post沒辦法
 
5.URL(Uniform Resource Locator)

6.CGI (Common Gateway Interface)& Servlet
    a.語言 :
        CGI : PHP , c , Python , Perl
    Servlet : Java
    
    b.比較
        CGI : @多用Process處理(搞肛),
              @Servlet使用Thead
              @Servlet可以寫在JavaEE裡面, CGI只能呼叫

minglight 發表在 痞客邦 留言(0) 人氣()

1. java.lang.Class代表class or Interface;
    class : 基本class, array ,enum , primitive type , void
    interface : interface , annotation
    +isInterface():boolean
    +isArray():boolean
    

2.用obj.class or obj.getClass()可以得到Class物件, 是在建立.class檔案時放入的
   因此也可以用Class.forName("ming.MyClass");方式得到Class物件
   
3.Class物件訊息在建立.class檔案就已經儲存好,編譯時期檢查相對應的.class檔案,
  Runtime會將有被使用到的Class資訊Load入定義區,因此有.class不一定會在定義區內,就不能做成物件
  使用Class.forName("package.name");將Class註冊入定義區中,並且將此Class回傳
  ==>Class.forName("package.name").newInstance();就會回傳此物件
  ps.只能new無參數建構子,如果沒有此定義就會出錯,也可以使用myClass.getConstructor.newInstance(Object...)來彌補有參數建構子的不足

4.使用Class物件可以得到各式各樣類別的定義, Constructors, Fields, Methods, package, SuperClass等

minglight 發表在 痞客邦 留言(0) 人氣()

最常犯的邏輯上的錯誤是 沒考慮到null的情形 而做instanceof , 卻又要在裡面做null判斷

ex :

public void m1(Object s1){

if(s1 instanceof  String){

if(s1 == null || "".equals(s1)){

sout("S1不存在!!");

}

}

}

上面這個例子, null情形永遠不會發生sout

 

另外一個rookie mistake是complie time error ,反而就沒那麼致命了

(reference  instanceof Class or Array)

int i = 0

if( i instanceof Integer) {

sout(i);

}

上面會出現要求你instanceof前面要放reference 不能放primitive type

minglight 發表在 痞客邦 留言(0) 人氣()

<code> 
var emp = function(config){
                                this.name ;
                                this.nick ;
                                this.stand = function(){
                                        document.write(this.name +" " + this.nick);
                                }
                                this.init = function(){
                                        //也可以是反過來
                                        this.name = this.name? this.name : config.name;
                                        this.nick = this.nick ? this.nick :config.nick;
                                        this.stand();

                                };
                                this.init();
                                this.stand();
                    }


                        var conf = {name:"Hank",nick:"ming"};
                        var _emp = new emp(conf);
                        //_emp.init();
                        //_emp.stand();
</code>

可以在stand()內執行要執行的東西! GOOD 物件化!

 

用this 而不用 var 的好處是
          1. 可以直接把屬性抓出來用! 比較好用
          2. 可以用override的方式去改寫某些屬性

minglight 發表在 痞客邦 留言(0) 人氣()

1.先去弄個跳線(好像是雙頭不一樣的訊號)應該可以自己買
   ps.改天來自己學接網路線頭

2.一臺設定 192.168.0.1   255.255.255.0
    另依臺    192.168.0.2   255.255.255.0

3.執行---> //192.168.0.1
    即可連線

//以上為電台工程課大大鵬智  未來課長候選人的精闢講解
  晚一點把詳情來查清楚 :P
  改天來試試看

minglight 發表在 痞客邦 留言(0) 人氣()

«12