Exemplo n.º 1
0
 public static BaseVO getBaseVO(String voClassName) {
   BaseVO baseVO = newBaseVOInstance(voClassName);
   VOConfig voConfig = VOMapping.getVOConfigByVoName(voClassName);
   if (voConfig == null) {
     throw new RuntimeException(
         voClassName + ":" + VOMappingExceptionConstant.VOMAPPING_PROPERTY_BEAN_NOT_CONFIGURATION);
   } else {
     // 只对vo的简单数据类型进行请求
     Map propertyMap = voConfig.getProperties();
     Iterator it = propertyMap.values().iterator();
     try {
       while (it.hasNext()) {
         SimpleProperty simpleProperty = (SimpleProperty) it.next();
         String voPropertyName = simpleProperty.getVoProperty();
         String voPropertyType = simpleProperty.getVoType();
         String obj = request.getParameter(voPropertyName);
         if (obj != null) {
           // TODO 编码处理
           Object voValue = BeanUtil.toDestValue(obj, voPropertyType);
           BeanUtils.setProperty(baseVO, voPropertyName, voValue);
         }
       }
     } catch (IllegalAccessException e) {
       log.error(e);
     } catch (InvocationTargetException e) {
       log.error(e);
     }
   }
   return baseVO;
 }
Exemplo n.º 2
0
 private static BaseVO newBaseVOInstance(String className) {
   BaseVO instance = null;
   try {
     instance = (BaseVO) Class.forName(className).newInstance();
   } catch (Exception e) {
     log.error(ExceptionConstant.IMTI_VO_EXTENDS_ERROR);
   }
   return instance;
 }