Mysql修改字段類型 UUID base64

1、修改mysql字段類型

alter table 表名 change 字段名稱 字段名稱 字段類型[是否允許爲空];

2、生成隨機數,用來生成如名字唯一圖片名稱

UUID uuid = UUID.randomUUID();//生成隨機數

3、base64解碼

imgData,base64編碼數據

BASE64Decoder decoder = new BASE64Decoder();
byte[] imageData = decoder.decodeBuffer(imgData);

FileOutputStream fos = new FileOutputStream(imgPath+imgName.jpg); 
fos.write(imageData);
fos.close();


問題1、

Map<String, String[]> params = request.getParameterMap();

for (String key : params.keySet()) {
System.out.println("key:"+key);   //key爲0
        String[] valueList = params.get(key);

String values = valueList[0];       //values:{"userId":"123","images":["base641","base642","base643"]}

        JSONObject jsStr = JSONObject.fromObject(values);
            userId = jsStr.getString("userId");
            images = jsStr.getString("images");
            JSONArray jsonArray = new JSONArray(images);
            int size = jsonArray.length();


發佈了27 篇原創文章 · 獲贊 12 · 訪問量 7萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章