日期:2014-05-18  浏览次数:20781 次

MultiActionController使用的问题
我在网上找到了一个例子:

package   org.springside.core.commons;

import   org.apache.commons.lang.ArrayUtils;
import   org.apache.commons.lang.StringUtils;
import   org.springframework.beans.propertyeditors.CustomDateEditor;
import   org.springframework.beans.propertyeditors.CustomNumberEditor;
import   org.springframework.util.Assert;
import   org.springframework.validation.BindingResult;
import   org.springframework.validation.ValidationUtils;
import   org.springframework.validation.Validator;
import   org.springframework.web.bind.ServletRequestDataBinder;
import   org.springframework.web.servlet.ModelAndView;
import   org.springframework.web.servlet.mvc.multiaction.MultiActionController;
import   org.springframework.web.util.WebUtils;
import   org.springside.core.utils.DateUtil;

import   javax.servlet.http.HttpServletRequest;
import   javax.servlet.http.HttpServletResponse;
import   java.io.IOException;
import   java.text.SimpleDateFormat;
import   java.util.ArrayList;
import   java.util.Date;
import   java.util.List;

/**
  *   SpringSide   Multiaction   Controller鐨勫熀绫?
  *   瀵筍pring鐨凪ultiActionController浣滀簡灏戦噺鎵╁睍锛屼富瑕佹槸瀵规暟鎹粦瀹氭牎楠岀殑鎵╁睍,
  *   鍚屾椂澧炲姞浜唟@link   #saveMessage(HttpServletRequest,   String)   }锛屼竴涓獅@link   #rendText(HttpServletResponse,String)}
  *
  *   @author   calvin
  */
abstract   public   class   BaseController   extends   MultiActionController   {
        /**
          *   涓嶈缃换浣昦ction鍙傛暟鏃剁殑榛樿   Action.
          *   璇ュ嚱鏁板悕鐢眡xx-servlet.xml閰嶇疆鏂囦欢涓殑   methodNameResolver鑺傜偣閰嶇疆.
          */
        abstract   public   ModelAndView   index(HttpServletRequest   request,   HttpServletResponse   response)   throws   Exception;

        /**
          *   鍒濆鍖朾inder鐨勫洖璋冨嚱鏁?
          *   榛樿浠ateUtil涓殑鏃ユ湡鏍煎紡璁剧疆DateEditor鍙婂厑璁窱nteger,Double鐨勫瓧绗︿覆涓虹┖.
          *
          *   @see   MultiActionController#createBinder(HttpServletRequest,Object)
          */
        protected   void   initBinder(HttpServletRequest   request,   ServletRequestDataBinder   binder)   {
                SimpleDateFormat   dateFormat   =   new   SimpleDateFormat(DateUtil.getDatePattern());
                binder.registerCustomEditor(Date.class,   new   CustomDateEditor(dateFormat,   true));
                binder.registerCustomEditor(Integer.class,   new   CustomNumberEditor(Integer.class,   true));
                binder.registerCustomEditor(Double.class,   new   CustomNumberEditor(Double.class,   true));
        }

        /**
          *   浠嶳equest涓粦瀹氬璞″苟杩涜鏍¢獙.