發表文章

目前顯示的是有「Spring」標籤的文章

Srping MultiactionController 使用綁定的設定

跟simpleform controller一樣,先在xml中設定好validator 只要validator的support有支援到在multiaction controller中的command的時候 就會採用該valiodator 接下來新增一個MyMultiacitonController 擴展原本的multiaction controller public class MyMultiactionController extends MultiActionController { //用來儲存binding error的model private Map errorModel = null; //以下是修改原始程式碼的結果 @Override protected void bind(HttpServletRequest request, Object command) throws Exception { logger.debug("Binding request parameters onto MultiActionController command"); ServletRequestDataBinder binder = createBinder(request, command); binder.bind(request); if (getValidators() != null) { for (int i = 0; i if (getValidators()[i].supports(command.getClass())) { ValidationUtils.invokeValidator(getValidators()[i], command, binder.getBindingResult()); } } } if (binder.getBindingResult().hasErrors()) { setErrorModel(binder.getBindingResult().getModel()); } } public Map getErrorModel() { Map map = this.errorModel; this.errorModel = n...

序曲Overture

目前主要拜讀的是良葛格的Spring技術手冊,一開始還摸不著頭緒,現在才發現原來讀技術書不是逐頁翻讀,而是要根據自己的需求,整理出自己要學習的方向,再逐一找出答案,這樣反而速度快多了,先前真的是浪費太多的時間在瀏覽內容,當然其他內容的涉獵也是不可少的。 在網路上看見許多人都把自己程式學習的過程紀錄在自己的部落格上,不但能幫助自己整理重點跟記錄問題,以備將來查詢之用,更能與其他網友們分享自己學習的成果,何樂而不為呢?