頁面有時候要增埋監聽事件,又怕被綁在物件上的事件影響時,有以下順序可以作為參考切入點

EX:
1. 連結裡埋一個onclick事件
2. 連結設為 https://www.google.com.tw/ 
3. 再分別設3個監聽.on()事件

<a id="testID" onclick="alert('tagOnclick');" href="https://www.google.com.tw/">
For test
</a>
$("#testID").on('click', function(event){
    alert("1");
});

$("#testID").on('click', function(event){
    alert("2");
});

$("#testID").on('click', function(event){
    alert("3");
});

 

RESULT:

alert('tagOnclick');
alert('1');
alert('2);
alert('3');
location to https://www.google.com.tw/

文章標籤

咪卡恰比 發表在 痞客邦 留言(0) 人氣()

判斷string是否是數字

NumberUtils.isNumber(string) =>將被廢棄,建議使用 isCreatable(String)

現在發布的 Class NumberUtils 底層可以看到直接轉用 isCreatable(String)了

 

/**
 * NumberUtils.isNumber Deprecated. 
 * This feature will be removed in Lang 4.0, use isCreatable(String) instead
 */
NumberUtils.isNumber("123");  //true
NumberUtils.isNumber("qwe");  //false
NumberUtils.isCreatable("123");  //true
NumberUtils.isCreatable("qwe");  //false
NumberUtils.isCreatable(""); //false
NumberUtils.isCreatable("    "); //false
NumberUtils.isCreatable(null); //false

 

https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/math/NumberUtils.html#isNumber-java.lang.String-


文章標籤

咪卡恰比 發表在 痞客邦 留言(0) 人氣()

要驗證的資料加上@Validated注解,表示spring必須對其進行檢核,BindingResult 則存放檢核後的訊息  (此兩值需相鄰)。

public ResultView quoteValidate(@Validated DataVO dataVO , BindingResult resul) {

}

 

多個資料需要檢核的話,則一對一對設定 ->

(@Validated DataOneVO dataOneVO , BindingResult resul ,@Validated DataTwoVO dataTwoVO , BindingResult resul);

 

 

 


文章標籤

咪卡恰比 發表在 痞客邦 留言(0) 人氣()

透過CALL  http://ifconfig.me的API取得機器對外IP

curl ifconfig.me


文章標籤

咪卡恰比 發表在 痞客邦 留言(0) 人氣()

從其他DB取得資料並更新到目的TABLE

update tableA  --target table
set(
tid,
tname
)=
(
select TB.prodId, TB.ProdName  --source data
from tableB TB
where TB.id = 123456
)
where tag = 'tag123'  --target table condition

文章標籤

咪卡恰比 發表在 痞客邦 留言(0) 人氣()

使用hibernate 5 取序號異常狀況,DB為oracle,ID生成annotation設定如下


public class OrderDet implements Serializable {

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO, generator="OrderDetSeq")
    @SequenceGenerator(name="OrderDetSeq", sequenceName="ORDERDET_SEQ")
    @Column(name="ID")
    private BigInteger id;

    public BigInteger getId() {
        return id;
    }

    public void setId(BigInteger id) {
        this.id = id;
    }
}

 

例如:DB SEQ為100,預期取出為101 (SEQ.nextval),但實際為60

這個問題在hibernate 4沒遇到,查了一下主要是以下原因

生成器演算法的調整(V4 to V5):
(old)   hi/lo: it uses the hi/lo algorithm and it’s equivalent to the original seqhilo generator.
(new) pooled: This optimizer uses a hi/lo optimization strategy, but the current in-memory identifiers highest boundary is extracted from an actual database sequence value.

hibernate 5會產生一個生成池供程式使用,避免多次去讀取DB,當池內數值用完,再去DB取一段SEQ回來(DB.SEQ會向後推一段空間),

文章標籤

咪卡恰比 發表在 痞客邦 留言(0) 人氣()

取得當前類名、方法名


public class AbcTest{
  @Test
  public void testMethod() throws Exception {
    //AbcTest.testMethod
    System.out.println(this.getClass().getSimpleName()+"."+Thread.currentThread().getStackTrace()[1].getMethodName());
  }
}

文章標籤

咪卡恰比 發表在 痞客邦 留言(0) 人氣()