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";
        }
    }
    

      

  • 相关阅读:
    linux常用命令笔记
    head first html与css
    多线程编程核心技术日记
    nio
    排序算法
    随笔
    数据库读写分离
    购物网站设计
    http
    servlet初始化
  • 原文地址:https://www.cnblogs.com/418836844qqcom/p/10855143.html
Copyright © 2011-2022 走看看