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();