2019 年 7 月 1 日,GOOGLE發佈會以行動版內容進行優先索引(過往是用電腦版網頁內容)。

在此情況下,GOOGLE建議對於 電腦版、行動版網站有不同獨立網址(非RWD網站)的網站,可進行以下的調整:

  • 行動版網站內容和電腦版網站相同。 (這個一般蠻難的)
  • 行動版和電腦版網站皆應包含結構化資料。 
  • 行動版和電腦版網站皆應包含中繼資料。 (調整一下雙頁面對應的META DATA)
  • Search Console 驗證電腦版和行動版網站。
  • 設定 hrfelang 資料:

行動版網址: m.aaa.com
電腦版網址:www.aaa.com

  • 行動版頁面需設定電腦版網址:
    <link rel="canonical" href="https://www.aaa.com/"> 
  • 電腦版頁面需設定電腦版和行動版網址:
    <link rel="canonical" href="https://www.aaa.com/"> 
    <link rel="alternate" href="https://m.aaa.com/">

REF.  https://developers.google.com/search/mobile-sites/mobile-first-indexing#mobile


文章標籤

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

 use JSTL 

model.addAttribute("listData", listData);
<c:forEach items="${listData}" var="listData">
    ${listData.name}
</c:forEach>

 

 use JS 

model.addAttribute("listData", new Gson().toJson(listData));
var listData = JSON.parse('${listData}');
$.each(listData, function(i){
    listData[i].name;
});

文章標籤

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

String sql = "...... from Tabal where col in (:colList)";

SQLQuery query = getCurrentSession().createSQLQuery(sql);
query.setParameterList("colList", String[] colValue);
query.list()

文章標籤

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

Method visibility and@Cacheable/@CachePut/@CacheEvict

When using proxies, you should apply the @Cache*annotations only to methods with public visibility.

If you do annotate protected, private or package-visible methods with these annotations, no error is raised, but the annotated method does not exhibit the configured caching settings. Consider the use of AspectJ (see below) if you need to annotate non-public methods as it changes the bytecode itself.

 

Ref : https://docs.spring.io/spring/docs/3.2.0.RC1/reference/html/cache.html

 


文章標籤

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

service需先進行delect 再select新資料

service:

@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
  public List<CreditCardInfoResponse> getCreditCardList(Long fridayUid) {
      //移除資料
      prodDao.deleteByProdId(prodId);
      prodDao.flush();
      
      //撈取資料
      List<prod> prodList = prodDao.findByProdId(ProdId);
  }

Dao

  public interface prodDao{
  
        public List<prod> findByProdId(Long prodId);
        
        @Modifying
        @Transactional
        @Query("delete from Prod where prodId = :prodId")
        public int deleteByIdFridayUidAndIsDefault(Long prodId);
  }

==>

如果表定Query,實際對資料庫操作

1.  delete from PROD  where PRODID=?

2.  select PRODID, PRODNAME from PROD  where PRODID=?

文章標籤

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

ajax的return要特別注意寫法,用變數接回再傳

$(function () {
    var console.log(testGetResult());   // 抓不到預期的boolean , show undefined
        var console.log(testGetResult2());  // show true or false
});

function testGetResult() {
        $.ajax({
        url: '/getData.do',
        type: 'get',
                async: false,
                success: function (res) {
            return true;
        },
        error: function (res) {
            return false;
        }
    });
}

function testGetResult2() {
        var rtn;
    $.ajax({
        url: '/getData.do',
        type: 'get',
                async: false,
                success: function (res) {
            rtn = true;
        },
        error: function (res) {
            rtn = false;
        }
    });
        return rtn;
}

文章標籤

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

java Data object 用 JSONObject.fromObject 或 JSONArray.fromObject做轉換的時候,
會轉成一個[ object object]的模式,如下:

"itemDateFrom":{"date":18,"hours":0,"seconds":0,"month":8,"nanos":0,"timezoneOffset":-480,"year":119,"minutes":0,"time":1568736000000,"day":3}

因為和預期 ( YYYY/MM/DD ) 不同,可以加入自定義轉換方式

  1. 先自定一個轉換定義
public class DateValue implements JsonValueProcessor{

        private String format ="yyyy/MM/dd";  
        
        public DateValue(){
                super();
        }
        
        public DateValue(String datePattern){
                super();  
        this.format = datePattern;
        }
        
        @Override
        public Object processArrayValue(Object value, JsonConfig config) {
                return process(value);
        }

        @Override
    public Object processObjectValue(String key, Object value, JsonConfig config) {   
        return process(value);   
    }
        
    private Object process(Object value){
        if(value instanceof Date){
                SimpleDateFormat sdf = new SimpleDateFormat(format);    
            return sdf.format(value); 
        }   
        return value == null ? "" : value.toString();   
    }
}
  1. 進行轉換
JsonConfig jsonConfig = new JsonConfig();
jsonConfig.registerJsonValueProcessor(Date.class , new DateValue());
//jsonConfig.registerJsonValueProcessor(Date.class , new DateValue("yyyy-MM-dd"));
JSONArray.fromObject(rtnProductUsableVoList,jsonConfig);

 


文章標籤

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