qq_35785520 2017-08-09 09:40 采纳率: 0%
浏览 472

springmvc 这个方法的用法谁懂

public static final T getModelMapObject(Class type, String modelMapAttrKey, HttpServletRequest request, ModelMap modelMap, T defaultValue) {
T modelMapAttrValue = defaultValue;

    if (null != type && null != modelMapAttrKey) {
        Object modelMapAttrValueObject = null;

        if (null != modelMap) {
            modelMapAttrValueObject = modelMap.get(modelMapAttrKey);
        } // if (null != modelMap)

        if (null == modelMapAttrValueObject && null != request) {
            modelMapAttrValueObject = request.getAttribute(modelMapAttrKey);
            if (null != modelMapAttrValueObject && null != modelMap) {
                modelMap.addAttribute(modelMapAttrKey, modelMapAttrValueObject);
            } // if (null != modelMapAttrValueObject && null != modelMap)
        } // if (null == modelMapAttrValueObject && null != request)

        if (null != modelMapAttrValueObject) {
            if (modelMapAttrValueObject.getClass() == type) {
                modelMapAttrValue = (T) modelMapAttrValueObject;
            } else {
                if (Boolean.class == type && modelMapAttrValueObject instanceof Integer) {
                    if (1 == (Integer) modelMapAttrValueObject) {
                        modelMapAttrValue = (T) new Boolean(true);
                    } else {
                        modelMapAttrValue = (T) new Boolean(false);
                    }
                } else if (Map.class == type && modelMapAttrValueObject instanceof Map) {
                    modelMapAttrValue = (T) modelMapAttrValueObject;
                } else if (List.class == type && modelMapAttrValueObject instanceof List) {
                    modelMapAttrValue = (T) modelMapAttrValueObject;
                }
            }
        } // if (null != modelMapAttrValueObject)
    } // if (null != type && null != modelMapAttrKey)

    return modelMapAttrValue;
}
  • 写回答

1条回答 默认 最新

  • zqbnqsdsmd 2018-06-14 16:27
    关注
    评论

报告相同问题?

悬赏问题

  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料