2012年8月5日 星期日
tomcat default character encoding
in default Tomcat request, we can get null from request.getCharacterEncoding().
what's the default value from Tomcat?
the default value is ISO-8859-1, now we start to trace this path!!
reference:
http://www.docjar.com/html/api/org/apache/catalina/connector/Request.java.html
in method parseParameters():
2496 protected void parseParameters() {
2497
2498 parametersParsed = true;
2499
2500 Parameters parameters = coyoteRequest.getParameters();
2501
2502 // getCharacterEncoding() may have been overridden to search for
2503 // hidden form field containing request encoding
2504 String enc = getCharacterEncoding();
2505
2506 boolean useBodyEncodingForURI = connector.getUseBodyEncodingForURI();
2507 if (enc != null) {
2508 parameters.setEncoding(enc);
2509 if (useBodyEncodingForURI) {
2510 parameters.setQueryStringEncoding(enc);
2511 }
2512 } else {
2513 parameters.setEncoding
2514 (org.apache.coyote.Constants.DEFAULT_CHARACTER_ENCODING);
2515 if (useBodyEncodingForURI) {
2516 parameters.setQueryStringEncoding
2517 (org.apache.coyote.Constants.DEFAULT_CHARACTER_ENCODING);
2518 }
2519 }
if we don't add any configuration in /conf/server.xml, it will use default value.
==>
reference:
http://www.docjar.com/html/api/org/apache/coyote/Constants.java.html
the constant:
27 public final class Constants {
28
29
30 // -------------------------------------------------------------- Constants
31
32
33 public static final String DEFAULT_CHARACTER_ENCODING="ISO-8859-1";
shows the default value for Tomcat character encoding!!
if you wanna change setting in server.xml, pls refer to https://confluence.atlassian.com/display/DOC/Configuring+Tomcat's+URI+encoding.
2011年3月4日 星期五
eclipse derby plug-in設定
一開始要先到Apache DB Project官網下載derby的檔案,目前的版本與路徑在
http://db.apache.org/derby/releases/release-10.7.1.1.cgi
進去後會看到
上面有很多種類型的檔案可以下載,但我們只需要這兩個for eclipse的~~
下載完後解壓縮會看三個資料夾名稱,分別是
org.apache.derby.core_10.7.1
org.apache.derby.ui_1.1.2
org.apache.derby.plugin.doc_1.1.2
這時候請別和我一樣雞婆,再進去這些資料夾裡,把它裡面的檔案一個一個抓出來,要記得直接將上述三個資料夾(_後的的版本可能會和你的不一樣,其它大致會相同)放到ecpilse安裝目錄內的plugins資料夾內,再重開eclipse就可以了。
接下來的安裝請參考輔大資管系eoffice版上的一篇文章~~
http://eoffice.im.fju.edu.tw/phpbb/viewtopic.php?t=6156
http://eoffice.im.fju.edu.tw/phpbb/viewtopic.php?p=24397
2011年2月28日 星期一
eclipse 自動完成 completion
在eclipse內,如果碰上平時使用alt+/可以出現的自動完成無法運作時,可以試試以下這個網址所述的:
http://stackoverflow.com/questions/908489/eclipse-java-code-completion-not-working
以英文版的eclpise而言,進入preferences -> Java -> Editor -> Content Assist -> Advanced,然後把東西勾一勾,如下圖就完成囉~~
2011年2月24日 星期四
ANTLR筆記
[ lexer | parser | tree ] grammer Name : ANTLR宣告,Name必須與檔名相同。
=====
options { ... } : ANTLR的設定值
- language = Java; 此為預設值,改語言直接改等號右邊的內容即可,注意大小寫。
- tokenVocab = xxxLexer for rule, or xxxParser for tree。
=====
@header { ... } : 產生出的java檔的表頭
- 通常放import或package的定義等
- 可以更進階的定義成 @parser::header { ... } or @lexer::header { ... },這樣就能分開定義在分開的檔案中。
=====
@members { ... } : 定義產生出的類別"成員與方法",也就是等於在裡面直接寫target language code的意思。
=====
若在重覆的規則中,要取得每個重覆的值,可以:
ee returns [int value]
: a1=INTT {$value+=Integer.parseInt($a1.text);}
('+' a2=INTT {
$value+=Integer.parseInt($a2.text);
System.out.println($value);
}
)+NEWLINE ;
上述的重點在於a2的左右大括號必須在()+內撰寫,這樣才能取得每一次的值,否則在()+後寫,會只找到最後一個值。
=====
如果要取一個parser邏輯的所有內容,則可以使用$text即可。例如:
statement:
'if' parExpression a1=statement ('else' statement)? { System.out.println("node: " + "if"); System.out.println("status: " + "else"); System.out.println("statement: " + $a1.text);
}
這裡的$a1.text是指第一個statement,但如果直接印出$text就會出現與這個規則符合的全部字串。
=====
在eclipse中,增加jvm的heap memory空間
在執行java程式時,碰上了錯誤是
java.lang.OutOfMemoryError: Java heap space
雖然知道是啥,但是不知道eclpise在哪改,事實上只要到run -> run Configuration,在(x)= Arguments的分頁內的VM argument中,輸入自己想要的空間即可~~
-Xmx512m
以上的意思是說,把heap memory設定為512MB。
附圖如下:
2011年2月2日 星期三
解決php存取mysql的亂碼問題
mysql_query("SET NAMES 'utf8'");
//要從資料庫顯示utf-8資料要加三行--第一行
mysql_query("SET CHARACTER_SET_CLIENT=utf8");
//第二行
mysql_query("SET CHARACTER_SET_RESULTS=utf8");
//第三行
搞定~~
2011年1月25日 星期二
flash loadvariable顯示&字元
說到這,flash真的很爛= =還得用這種爛方法....
如果用loadvariable讀取外部檔案來當作自己的資料時~~
通常是用:
loadVariables("xxx.txt", "xxxx");
然後xxx.txt裡面就可以這麼寫:
&title=xxx;
&name=xxx;
今天忽然要用到這種東西:
&school=A&M Texus
結果flash居然給我切開了 = =,試了\&,&&,"&"沒一個有用,最後發現是....
把&換成%26的編碼= =搞定= =(記得把txt檔改成utf-8的編碼,不然網路上說不會過,當然我懶得試...)
GOOGLE的搜尋字串為:"flash loadVariables escape &"
btw, 雙引號別忘了加,不然抓不到&這個字喔~~~