2017年2月上半月工作日志

一、图片上传

HTML <input> 标签的 accept 属性
在文件上传中使用 accept 属性,本例中的输入字段可以接受 GIF 和 JPEG 两种图像:
<input type="file" name="pic" id="pic" accept="image/gif, image/jpeg" />
如果不限制图像的格式,可以写为:accept="image/*"。accept 属性只能与 <input type="file"> 配合使用。它规定能够通过文件上传进行提交的文件类型。
HTML 5 <input> type 属性:http://www.w3school.com.cn/html5/att_input_type.asp


图片上传插件,可实现图片上传、预览和缩放。

cropit插件 : http://scottcheng.github.io/cropit/


FileInputStream 用于读取诸如图像数据之类的原始字节流。要读取字符流,请考虑使用 FileReader。
byte data[] = new byte[length]:length最大应该是Integer.MAXVALUE,即2147483647,int数据最大是2^31-1。

二、ajax基础

//(默 认: 自动判断 (xml 或 html)) 请求失败时调用时间。
//参数有以下三个:XMLHttpRequest 对象、错误信息、(可选)捕获的错误对象。
//如果发生了错误,错误信息(第二个参数)除了得到null之外,
//还可能是"timeout", "error", "notmodified" 和 "parsererror"。
//textStatus: "timeout", "error", "notmodified" 和 "parsererror"。
error:function (XMLHttpRequest, textStatus, errorThrown) { 
  
} 

三、CSS基础

display: flex;
align-items: center;
实现效果:垂直居中

四、Java基础

java中打印数组的5种方法

    Arrays.toString(arr)  
      
    for(int n: arr)   
       System.out.println(n+", ");  
      
    for (int i = 0; i < arr.length; i++) {  
       System.out.print(arr[i] + ", ");  
    }  
      
    System.out.println(Arrays.asList(arr));  
      
    Arrays.asList(arr).stream().forEach(s -> System.out.println(s));//java8 

retainAll方法去重:对象不能实现,转换成字符串可以实现。
public static void main(String[] args) {
	Set<Object> list1 = new HashSet<Object>();
	list1.add(JSONArray.toJSONString(new AccountEntity("lily")));
	list1.add(JSONArray.toJSONString(new AccountEntity("jim")));
	list1.add(JSONArray.toJSONString(new AccountEntity("tom")));
	
	Set<Object> list2 = new HashSet<Object>();
	list2.add(JSONArray.toJSONString(new AccountEntity("tom")));
	list2.add(JSONArray.toJSONString(new AccountEntity("tony")));
	list2.add(JSONArray.toJSONString(new AccountEntity("lily")));
	
	list1.retainAll(list2);
	Iterator<Object> it = list1.iterator();
	while (it.hasNext()) {
		System.out.println(it.next());
	}
}

原文地址:https://www.cnblogs.com/archermeng/p/7537108.html