Ejemplo n.º 1
0
 /** 保存对象到attribute */
 public static void putRequestAttribute(HttpServletRequest req, Object re) {
   if (null != re) {
     if (re instanceof Context) {
       Context context = (Context) re;
       for (String key : context.keys()) {
         req.setAttribute(key, context.get(key));
       }
     } else {
       req.setAttribute(ViewProcessor.DEFAULT_ATTRIBUTE, re);
     }
   }
 }
Ejemplo n.º 2
0
  public Object calculate() {
    // 如果直接调用计算方法,那基本上就是直接调用属性了吧...我也不知道^^
    Object obj = fetchVar();
    if (obj == null) {
      throw new ElException("obj is NULL, can't call obj." + right);
    }
    if (obj instanceof Map) {
      Map<?, ?> om = (Map<?, ?>) obj;
      if (om.containsKey(right.toString())) {
        return om.get(right.toString());
      }
    }
    if (obj instanceof Context) {
      Context sc = (Context) obj;
      if (sc.has(right.toString())) {
        return sc.get(right.toString());
      }
    }

    Mirror<?> me = Mirror.me(obj);
    return me.getValue(obj, right.toString());
  }