2022年5月18日 星期三

Eclipse無法自動編譯出class檔案

 最近幫位新手(非新人)解Bug說專案跑不起來,顯示

Spring專案啟動有Exception
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find classs ...

看了下專案目錄bin下面沒東西,正常應該會有對應.javs的.class檔案,做個備忘囉~~小卡關以後萬一碰到可以參考。

Eclipse 的設定參考這篇網誌可以初步排除些設定上的問題,clean執行完後或是JDK移除重設定還怪怪的話,重啟Eclipse可以試試!! 不過這次碰上的個案不是這類的問題。

底下位置紅框處若有紅色X項時,要選取後選擇delete若沒清掉也無法Build,至於新手說他的另一個專案也有紅色X項但是可以build跟執行,=.= 這樣子喔...BJ4 







byte[] 與String 轉換中文亂碼備忘

姓名跟住址這類資料存取往往都會跟CharSet有關,如果某個環節沒弄好就是亂碼+破版來回報,做個備忘嚕!!

String CharSet = "UTF-8";
byte[] bytes_rowdata = s_addr.getBytes(CharSet );
String s_Addr = ArrayCopy2Str(bytes_rowdata, 0, 11, 20, CharSet );

/*
 * i_posstr: 相對起始位置
 * i_offset: 偏移位
 * len: 取的字元長度
 * CharSet: 字元編碼 
*/
private String ArrayCopy2Str(byte[] bytes_rowdata, int i_posstr, int i_offset, int len, String CharSet ) {

String s_val = "";
try {
vResult = new byte[len];
System.arraycopy( bytes_rowdata, i_posstr + i_offset, vResult, 0, len);
                        //還原字串也要設定字元編碼,如果沒給那一定機率會變亂碼
s_val = new String(vResult, CharSet);
} catch (Exception ex) {
System.out.println("ArrayCopy2Str has exception:" + ex.toString());
}

return s_val;
}

2022年5月17日 星期二

把JS ALERT變漂亮

 當系統開發運行趨於穩定後,使用者開始對UI/UX的需求就會趨向積極,恩恩...對單純的Programmer來說,美感永遠不是得優先強化的項目,當然嘔心瀝血做了好幾天更新上的版面,被吐槽到爆炸的評語帶來的挫折也不是一天兩天就能平復的,總之...依賴第三方套見是個不錯的選擇。

SWEETALERT2 可支援BootStrap是不錯的選擇,官網上的範例也很豐富大概常用的情境都有了,要更炫目的也有但使用者口味是會被養刁的,不要隨便做害人(舉某系統說他有位啥你沒有)害己(其他業管的系統為啥沒有)的決定。

取代alert();

Swal.fire("訊息","Hello world.","error");

取代comfirm();

Swal.fire({

  title: "警告",
  icon: "info", //warring(orange), primary(dark blue), info(blue), success(green), danger(red)
  html: "<font color='red'>查無OOOOO<br>請再次確認</font>",
  showCloseButton: false,
  showCancelButton: true,
  focusConfirm: false,
  confirmButtonText: "提交",
  cancelButtonText: "取消",
}).then((result) => {
  if (result.isConfirmed) {
  //Do something.;
  }

})