senario: 佈署了 security HTTP後, user很不爽每次 IE都會出現憑證錯誤,是否繼續瀏覽然後得按繼續瀏覽才能進到頁面.
solution:
叫 user手動接受我們產生的自簽核憑證(sellf-signed certification).
不過,還是得處理一下我們的自簽核憑證才能順利讓 user接受憑證
錯誤訊息有三:
1.此網站出示的安全性憑證並非由信任的憑證授權單位所發行。
ans:這部份需要 user手動接受.首先,須將本網站加到信任的網站(網際網路選項>安全性>信任的網站,細節不贅述.然後點選網址列最右邊的憑證錯誤,在打開的視窗中點安裝憑證(先加信任網站才會有安裝憑證可以點),然後把憑證安裝到信任的憑證區.
2.此網站出示的安全性憑證已過期或尚未生效
ans:夠清楚了,憑證過期.那憑證如果是別人發行的,就只好檢查或改改自己的電腦時間.但是我們是發行者,憑證有效期限要多久我們自己可以決定.
keytool -genKey -keyalg RSA -alias <%aliasName%> -keystore <%keystore-path%> -storepass 1234qwer -validity 10000 -keysize 2048 -dname "CN=abc.com, OU=def, O=ghi, L=jkl, S=mno, C=pqr"
-validity 10000就是代表從下這個指令開始,產生的憑證在 10000天內有效:)
3.此網站出示的安全性憑證是為其他網站的位址所發行的
ans:上面那個 keytool指令, -dname中的 CN就是瀏覽器用來判斷"位址不符"的根據.把 CN改成自己的網址(不用加 https://)就符了.
code_prettify
2014年4月9日 星期三
tomcat+struts url querystring中文編碼解碼
senario: xmlhttprequest GET傳送含中文資料到 action, AP Server tomcat 6.x, struts 1.x
solution:
1. url path沒有中文,只有傳遞的參數有中文,所以對參數做 encodeURIComponent
2. tomcat \conf\server.xml中 Connector並未設定 URIEncoding屬性(因此為預設值 ISO-8859-1)
3. request.getParameter 會做 URLDecode, 但是因為 2., 所以得到的中文是 ISO-8859-1編碼
4.對request.getParameter重新編碼就拿到想要的 utf-8 encoded string
new String(req.getParameter("xxx").getBytes("ISO-8859-1"), "utf-8");
solution:
1. url path沒有中文,只有傳遞的參數有中文,所以對參數做 encodeURIComponent
2. tomcat \conf\server.xml中 Connector並未設定 URIEncoding屬性(因此為預設值 ISO-8859-1)
3. request.getParameter 會做 URLDecode, 但是因為 2., 所以得到的中文是 ISO-8859-1編碼
4.對request.getParameter重新編碼就拿到想要的 utf-8 encoded string
new String(req.getParameter("xxx").getBytes("ISO-8859-1"), "utf-8");
2014年3月19日 星期三
jquery 五種取 selected text的方法
console.log($('select[name="leave_type_auto_id"] option:selected').text());
console.log($('select[name="leave_type_auto_id"] option').filter(':selected').text());// optimized(maybe)
console.log($('select[name="leave_type_auto_id"]').children().filter(':selected').text());
console.log($('select[name="leave_type_auto_id"]').children('option').filter(':selected').text());// fastest(maybe)
console.log($('select[name="leave_type_auto_id"]').children('option:selected').text());
console.log($('select[name="leave_type_auto_id"]').children(':selected').text());// fastest(maybe)
有篇比較各種 selector速度的測試
http://jsperf.com/get-selected-option-text
console.log($('select[name="leave_type_auto_id"] option').filter(':selected').text());// optimized(maybe)
console.log($('select[name="leave_type_auto_id"]').children().filter(':selected').text());
console.log($('select[name="leave_type_auto_id"]').children('option').filter(':selected').text());// fastest(maybe)
console.log($('select[name="leave_type_auto_id"]').children('option:selected').text());
console.log($('select[name="leave_type_auto_id"]').children(':selected').text());// fastest(maybe)
有篇比較各種 selector速度的測試
http://jsperf.com/get-selected-option-text
2014年3月12日 星期三
懶得寫 bean. java內建的 key value paire.
java.util.AbstractMap.SimpleEntry<K, V>(K, V).
腦袋一下轉不過來,一直無法建構
new java.util.AbstractMap.SimpleEntry<Integer, String>(new Integer(1), "foo");
腦袋一下轉不過來,一直無法建構
new java.util.AbstractMap.SimpleEntry<Integer, String>(new Integer(1), "foo");
2014年2月14日 星期五
Win7下 eclipse註解字型太小
網路上搜尋了一下,主要是因為字型的關係, 而非 font size.
eclipse - Window> Preferences> General> Appearance> Colors and Fonts> Java,選中Java Editor Text Font,點 Edit,把字型改成 Courier New就 OK了
如果點 Edit後字型沒 Courier New可選,在作業系統 - 控制台>外觀及個人化>字型,找到 Courier New右鍵選單選顯示,回 eclipse就有 Courier New可選了
eclipse - Window> Preferences> General> Appearance> Colors and Fonts> Java,選中Java Editor Text Font,點 Edit,把字型改成 Courier New就 OK了
如果點 Edit後字型沒 Courier New可選,在作業系統 - 控制台>外觀及個人化>字型,找到 Courier New右鍵選單選顯示,回 eclipse就有 Courier New可選了
2013年8月30日 星期五
synchronized method無效的假象
系統有個 table紀錄人員編號, entity為
public Class Foo {
private String prefix1;
private String prefix2;
private int serial;
}
有個取號程式會依(prefix1, prefix2)去取得目前流水號,並將 tablek的 serial加1.
為了避免多個 thread搶序號問題, 取號的 method(select and update table)加上了 synchronized.
但卻發現依然出現 serial重複的問題.
測了半天才發現是因為我們用 hibernate.
第二個 thread load entity時 return的是第一個 thread load後的 cache.
加上 session.clear()就解決了.
害我一直很擔心如果真的是 synchronized失效,不知道要加多少班解決這個問題了.
public Class Foo {
private String prefix1;
private String prefix2;
private int serial;
}
有個取號程式會依(prefix1, prefix2)去取得目前流水號,並將 tablek的 serial加1.
為了避免多個 thread搶序號問題, 取號的 method(select and update table)加上了 synchronized.
但卻發現依然出現 serial重複的問題.
測了半天才發現是因為我們用 hibernate.
第二個 thread load entity時 return的是第一個 thread load後的 cache.
加上 session.clear()就解決了.
害我一直很擔心如果真的是 synchronized失效,不知道要加多少班解決這個問題了.
2013年8月29日 星期四
Class org.apache.struts.chain.commands.util.ClassUtils can not access a member of class with modifiers ""
手殘把 public Class XXX的 public刪掉,成了 Class XXX就出現上述錯誤了
訂閱:
文章 (Atom)