1 国际化
2 转码
3 树状菜单
function getChildGroup(obj){
if($("#ul"+obj)[0]==undefined){
$.ajax({
url: "category.jhtml",
data: {"event":"child","uuid":obj},
dataType: "json",
type: "post",
success: function (datas) {
var ulEle = "<ul id='ul"+obj+"'>";
$.each(datas, function(i, data){
ulEle += "<li id='"+data.uuid+"' onclick='getChildGroup(this.id)'>"+data.name+"</li>";
})
ulEle +="</ul>";
$("#"+obj).after(ulEle);
}
});
}else if($("#ul"+obj)[0].style.display == 'none'){
$.ajax({
url: "category.jhtml",
data: {"event":"child","uuid":obj},
dataType: "json",
type: "post",
success: function (datas) {
var ulEle = "<ul id='ul"+obj+"'>";
$.each(datas, function(i, data){
ulEle += "<li id='"+data.uuid+"' onclick='getChildGroup(this.id)'>"+data.name+"</li>";
})
ulEle +="</ul>";
$("#"+obj).next().replaceWith(ulEle);
}
});
$("#ul"+obj).show()
}else{
$("#ul"+obj).hide()
}
$("#indexRight").html($.ajax({url:"category.jhtml?event=search&uuid="+obj,async:false}).responseText);
var arr = $("tr td:nth-child(1)")
arr.each(function(i,data){
if(i>0){
data.innerHTML = $("#"+obj).text();
}
});
}
4 分页代码
<input type="submit" name="prePage" value="上一页">
<#if totalPage < 3>
<#list 1..totalPage as t>
<#if t == pageIndex>
${t}<input type="hidden" id="pageIndex" name="pageIndex" value="${t}">
<#else>
<a href="javascript:Asubmit('${t}')">${t}</a>
</#if>
</#list>
<#elseif pageIndex < 3>
<#list 1..3 as t>
<#if t == pageIndex>
${t}<input type="hidden" id="pageIndex" name="pageIndex" value="${t}">
<#else>
<a href="javascript:Asubmit('${t}')">${t}</a>
</#if>
</#list>
<#else>
<#if pageIndex+2 < totalPage>
<#list 2..1 as t>
<a href="javascript:Asubmit('${pageIndex-t}')">${pageIndex-t}</a>
</#list>
${pageIndex}<input type="hidden" id="pageIndex" name="pageIndex" value="${pageIndex}">
<#list 1..2 as t>
<a href="javascript:Asubmit('${pageIndex+t}')">${pageIndex+t}</a>
</#list>
<#else>
<#list 2..1 as t>
<a href="javascript:Asubmit('${pageIndex-t}')">${pageIndex-t}</a>
</#list>
<#if totalPage = pageIndex>
${pageIndex}<input type="hidden" id="pageIndex" name="pageIndex" value="${pageIndex}">
<#else>
${pageIndex}<input type="hidden" id="pageIndex" name="pageIndex" value="${pageIndex}">
<#list 1..totalPage-pageIndex as t>
<a href="javascript:Asubmit('${pageIndex+t}')">${pageIndex+t}</a>
</#list>
</#if>
</#if>
</#if>
共:${totalPage}页
<input type="submit" name="nextPage" value="下一页"><input type="text" name="goToPage"><input type="submit" name="goTo" value="转向">
5.ibaits like '$name$' 传入时参数前后可拼接%
6.md5 方法
public static String getPassword(){ String model = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; StringBuilder sbf = new StringBuilder(); for(int i = 0;i<6;i++){ sbf.append(model.charAt((int)(Math.random()*62))); } return sbf.toString(); } public static String md5(String s) { char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; try { byte[] strTemp = s.getBytes(); MessageDigest mdTemp = MessageDigest.getInstance("MD5"); mdTemp.update(strTemp); byte[] md = mdTemp.digest(); int j = md.length; char str[] = new char[j * 2]; int k = 0; for (int i = 0; i < j; i++) { byte byte0 = md[i]; str[k++] = hexDigits[byte0 >>> 4 & 0xf]; str[k++] = hexDigits[byte0 & 0xf]; } return new String(str); } catch (Exception e) { return null; } }
7.java操作POI所需jar(针对2007以上版本)
xmlbeans2.3.0 dom4j1.6.1
8. java操作图片
BufferedImage image = ImageIO.read(item.getInputStream());
直接从inputstream获取图片
9.Ant打包
<?xml version="1.0" encoding="UTF-8"?> <project name="bbb" basedir="." default="source.jar"> <property name="src" location="${basedir}/bbb_source"/> <property name="source" location="${src}/source"></property> <property name="cvsroot" value=":pserver:[email protected]:/aaa"/> <target name="init"> <delete dir="${src}"/> <delete dir="${source}"/> <mkdir dir="${src}"/> <mkdir dir="${source}"/> </target> <target name="bbb-checkout" depends="init"> <cvspass cvsroot="${cvsroot}" password="zhangsongwei"/> <cvs cvsRoot="${cvsroot}" package="bbb/code" dest="${src}"/> </target> <!-- <target name="copy" depends="bbb-checkout">--> <target name="copy" depends="bbb-checkout"> <copy todir="${source}"> <fileset dir="${src}/bbb/code/common"></fileset> </copy> <copy todir="${source}"> <fileset dir="${src}/bbb/code/platform"></fileset> </copy> <copy todir="${source}"> <fileset dir="${src}/bbb/code/target"></fileset> </copy> </target> <target name="source.jar" depends="copy"> <jar destfile="${source}/bbb.jar" basedir="${source}"> </jar> </target> </project>