zoukankan      html  css  js  c++  java
  • map转换成String到数据库存储

    package com.fengshun.tst.entity;
    
    import com.alibaba.fastjson.JSON;
    import org.springframework.web.bind.annotation.GetMapping;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RestController;
    
    import javax.annotation.Resource;
    import javax.transaction.Transactional;
    import java.util.HashMap;
    import java.util.Map;
    
    @Transactional
    @RestController
    @RequestMapping("/sss/dict")
    public class TestController {
        @Resource
        TestService ts;
    
    
        @GetMapping("/test")
        public String test (){
            Map<String, String> map = new HashMap<>();
            map.put("123","456");
            map.put("178", "789");
            String str = JSON.toJSONString(map);
            TestEntity t = new TestEntity();
            t.setMap(str);
            t.setId("1");
            ts.save(t);
            return "1111111";
        }
        @GetMapping("/test1")
        public String test1 (){
            TestEntity t = ts.findOne("1");
            String map = t.getMap();
            Map maps1 = (Map)JSON.parse(map);
            System.out.println(maps1);
            return "22";
        }
    }
    

      

  • 相关阅读:
    关于float与double
    【编程实践】母牛生小牛
    wlan的QOS配置
    C语言itoa函数和atoi 函数
    类似于QQ的简单的聊天代码
    多线程吃饺子练习
    线程练习
    接口练习
    电视练习
    5.22
  • 原文地址:https://www.cnblogs.com/418836844qqcom/p/10855143.html
Copyright © 2011-2022 走看看