Jquery Ajax 保存
Jquery Ajax 保存:
$.ajax({
type:"POST",
async:false,
url:"${ctx}/url",
data: {pId:provinId},
success:function(returnData){
}
});
Jquery Ajax 保存:
$.ajax({
type:"POST",
async:false,
url:"${ctx}/url",
data: {pId:provinId},
success:function(returnData){
}
});
//高效率遍历Map以及在循环过程中移除 remove指定key//使用iter循环的时候 可以在循环中移除key,for在循环的过程中移除会报错哦//本方法效率高 Iterator iter =finalFenleiMap.entrySet().iterator();while(iter.hasNext()){
Map.Entry entry=(Map.Entry) iter.next();
Object key=entry.getKey();if(key!=null){
curKey=key.toString();if(curKey.indexOf("国内")!=-1){
finalFenleiMap.put(curKey, scenicList);
}else if(curKey.indexOf("出境")!=-1){
iter.remove();//移除出境 的专题 }
}
}
List根据对象的某个属性排序工具类 List排序importjava.util.Collections;importjava.util.Comparator;importjava.util.List;importorg.apache.commons.beanutils.BeanComparator;importorg.apache.commons.collections.ComparatorUtils;importorg.apache.commons.collections.comparators.ComparableComparator;public classListSortUtil {/*** 按bean的属性值对list集合进行排序
*
*@paramlist
* 要排序的集合
*@parampropertyName
* 集合元素的属性名
*@paramisAsc
* 排序方向,true--正向排序,false--逆向排序
*@return排序后的集合*/ public static List sortList(List list, String propertyName, booleanisAsc) {//借助commons-collections包的ComparatorUtils//BeanComparator,ComparableComparator和ComparatorChain都是实现了Comparator这个接口 if(list!=null && list.size()>0){
Comparator mycmp=ComparableComparator.getInstance();
mycmp= ComparatorUtils.nullLowComparator(mycmp); //允许null if(isAsc){
mycmp= ComparatorUtils.reversedComparator(mycmp); //逆序 }
Comparator cmp= newBeanComparator(propertyName, mycmp);
Collections.sort(list, cmp);
}returnlist;
}
}
img如果没有图片显示默认图片效果
<img src="本来要显示的图片URL" onerror="this.src='图片挂了的话要显示的默认图片URL'" />
其实就是说,在这个img的行为失败(onerror)的时候,调用javascript:
this.src="URL"
来给这个img标签重新指定src属性,从而达到显示备用图片的效果。
//保存路径 如file路径是E:\filer\a.jpg File toSaveFile=new File("filePath");if(toSaveFile!=null){
toSaveFile.mkdirs();//会自动创建文件夹 }