發表文章

eclipse format length

自動分行的字元長度設定: java Preferences -> Java -> Code Style -> Formatter / Edit -> Line wrapping -> Maximum line width html(include html and jsp) Preferences -> Web -> HTML Files -> Editor -> Line width xml Preferences > XML > XML Files > Editor > Line width 不要自動合併行設定: java Preferences -> Java -> Code Style -> Formatter / Edit -> Line wrapping -> Never join already wrapped lines html(include html and jsp) Preferences -> Web -> HTML Files -> Editor -> in line elements -> 移除不要併行的tag xml Preferences > XML > XML Files > Editor > 取消 join lines

修改MAC hostname主機名稱

修改方法: system Preferences - Sharing - Computer Name or Edit - Local Hostname 修改完成後重開機生效,在terminal的hostname也自動變更。 terminal指令:hostname 其他方法reference: sudo scutil --set HostName "newname" http://apple.stackexchange.com/questions/66611/how-to-change-computer-name-so-terminal-displays-it-in-mac-os-x-mountain-lion

Tomcat: A docBase inside the host appBase has been specified, and will be ignore

錯誤警告A docBase inside the host appBase has been specified, and will be ignore 因為${catalina.home}/webapps底下已經存在一個mywebapp, 而conf\Catalina\localhost\ROOT.xml 也指定同一個mywebapp的docBase, 導致啟動Tomcat時,檢測到webapp docBase已被載入過。 解決方法:將mywebapp移出 ${catalina.home}/webapps到其他路徑 reference http://blog.sina.com.cn/s/blog_7623ecc40100wvlo.html

架設VPN server

PPTP: 用win7內建的pptp vpn server L2TP: 用packetix vpn http://blog.xuite.net/sendohshih/blog/73932762 打開L2TP防火牆: windows->防火牆->進階設定->輸入規則->新增規則: Port->UDP:500,4500,1701 reference: http://blogs.technet.com/b/rrasblog/archive/2006/06/14/which-ports-to-unblock-for-vpn-traffic-to-pass-through.aspx

Ubuntu中安裝並設定VPN Server

Ubuntu中安裝並設定VPN Server http://igene.tw/vpn-server-install/

FB login error:Invalid redirect_uri

當FB login功能出現這個訊息: {    "error": {       "message": "Invalid redirect_uri: \u61c9....",       "type": "OAuthException",       "code": 191    } } 因為FB app限制redirect的ip或url,程式裡指定的redirect uri,必須符合fb app設定的資料,所以設定以下兩者之一,才能正常運作: 1.settings-basic-Site URL 2.settings-advanced- Security -Valid OAuth redirect URIs reference http://stackoverflow.com/questions/8100043/facebook-invalid-redirect-uri-but-the-url-looks-fine-to-me

servlet 用get傳中文參數

from: response.sendRedirect("./change?reason=" + URLEncoder.encode("售完", "UTF-8")); ps.將中文轉為UTF-8的URL to: String reason = request.getParameter("reason"); reason = new String(reason.getBytes("iso-8859-1"),"UTF-8"); ps.接收端無法使用request.setCharacterEncoding("UTF-8")接收get過來的中文參數,只能使用getBytes reference http://openhome.cc/Gossip/Encoding/Servlet.html 原文轉貼如下: 請求參數的編碼處理,基本上必須分POST與GET的情況來說明,我們先來看POST的情況… 如果客戶端沒有在Content-Type標頭中設定字元編碼資訊(例如瀏覽器可以設定Content-Type: text/html; charset=UTF-8),此時使用HttpServletRequest的getCharacterEncoding()傳回值會是null,在這個情況下,容器若使用的預設編碼處理是ISO-8859-1(大部份瀏覽器預設的字元集) 你可以使用HttpServletRequest的setCharacterEncoding()方法指定取得POST請求參數時使用的編碼。例如若瀏覽器以UTF-8來發送請求,則你接收時也要使用UTF-8編碼字串,則可以在取得任何請求值之「前」,執行以下陳述: request.setCharacterEncoding("UTF-8"); 在HttpServletRequest的API文件中,對setCharacterEncoding()的說明清楚提到: Overrides the name of the character encoding used in the body of this request. 也就是說,這個方法對於...