1. 程式人生 > 其它 >帝國cms文章頁呼叫當前文章URL如何操作?

帝國cms文章頁呼叫當前文章URL如何操作?

  1. 大整數10進位制轉16進位制問題 google了都沒什麼好的解決方法,因為要轉換的十進位制有300多位,long都裝不下,沒有直接可用的函式可以拿來用 王總的方法分享之: 思路:轉換10進位制字串為大整數 ,大整數放入位元組流,每個位元組轉換為16進位制,有空位補零 程式碼: import java.math.BigInteger; public static String convertDecimalToUpperHexStr(String decimalStr){ BigInteger bi = new BigInteger(decimalStr); byte[] bytes = bi.toByteArray(); StringBuilder sb = new StringBuilder(); int i=0; for(byte b : bytes) { String hexStr = Integer.toHexString(b & 0xFF); if (i==0&&"0".equals(hexStr)) i=1; else sb.append( hexStr.length()==1?("0"+hexStr):hexStr ); } return sb.toString().toUpperCase();  }
  2. 有意義的斜槓 對url http://ip:port/servername post資料有問題,最終發現是因為伺服器端把action對映到了“/” 瀏覽器訪問時會自動加斜槓可以獲取請求,而客戶端端請求無法找到指定action 導致錯誤。需要注意理解程式碼意義。
  3. android eclipse plugin url https://dl-ssl.google.com/android/eclipse/
  4. 透過apache nginx等代理獲取使用者ip
public static String getRemoteAddr(HttpServletRequest req) { 

String ip = req.getHeader("x-forwarded-for"); 

if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {

ip = req.getHeader("Proxy-Client-IP"); 

} 

if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 

ip = req.getHeader("WL-Proxy-Client-IP"); 

} 

if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 

ip = req.getRemoteAddr(); 

} 

return ip; 

}
  1. SVN的cache程式使得你的機器反應很慢的話,那可以參考這個方案.不過可能要改變你以前使用習慣. 關閉SVN的cache監視。即關閉tsvncache.exe這個程式對目錄的監視。 具體操作步驟如下: a) 右擊任意目錄開啟右鍵選單,開啟"tortoisesvn" => "settings"下的設定視窗 b) 找到"icon overlays"的設定項,將"status cache"設定成"none"
  2. java異常:java.lang.ClassFormatError: Truncated class file 實驗了好幾次 發現突然之間從自己xp機器上maven build的 class檔案 拷貝到伺服器上不能跑了,從測試機linux環境直接拷貝就沒事 無語。 最終發現是因為ssh裡選擇了將檔案作為binary傳輸造成的,去掉該選項就可以了
  3. org.apache.juli.ClassLoaderLogManager not found  JAVA_HOME 沒有設定 安裝後設置為/usr/local/jdk即可
  4. java.net.UnknownHostException sc-server02: sc-server02: 修改 /etc/hosts 127.0.0.1 localhost.localdomain localhost sc-server02
  5. IntelliJ IDEA  create patch Use the Changes view. In the group by directory mode you can right click on the directory with changes and choose Create Patch from the context menu. stackoverflow上的答案,其實很笨拙,在VCS選單選擇create 或 apply patch即可 ,有問題問help選單!
  6. IntelliJ IDEA  open Multiple Projects change remember 手賤選了remember 結果不能在新視窗打開了,在preferences 裡 general startup/shutdown裡把confirm window 選上就可以了
  7. System.currentTimeMillis 問題 它需要從使用者態到核心態切換,在 memcache 每秒上萬請求中大量使用會造成效能損耗。 因此將系統時間 cache 10ms, 在不需要10ms以下精度之處可以使用此方法