zoukankan      html  css  js  c++  java
  • springboot属性注入转化为对象

    第一种方式:用spel表达式解析

    @Value("#{ T(com.alibaba.fastjson.JSON).parseObject('${train.purchase}')}")
    private Map<String, String> purchaseMap;

    @Value("#{ T(com.alibaba.fastjson.JSON).parseObject('${train.purchase}')}")
    private Map<String, String> map;

    第二种方式:获取字符串后,自己解析

    return JSON.parseObject(supplier, new TypeReference<LinkedHashMap<String, String>>(){});

    第三种方式:自己实现属性编辑器,并注入到环境中

    public class DtoEditor extends PropertyEditorSupport {
    @Override public void setAsText(String text) throws IllegalArgumentException { String[] str = text.split(","); User user = new User(); user.setName(str[0]); user.setValue(str[1]); setValue(user); } @Override public String getAsText() { return null; } }
  • 相关阅读:
    r语言
    pickle模块
    mongodb简介
    oracle
    mysql
    ceph
    迭代器
    python类
    encode&decode
    PHP 截取字符串中某两个字符(串)之间的字符串 考虑多个的情况
  • 原文地址:https://www.cnblogs.com/tuifeideyouran/p/6560680.html
Copyright © 2011-2022 走看看