﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-Jerome Kwok〖旧日的足迹〗-文章分类-Java EE</title><link>http://www.blogjava.net/JeromeKwok/category/34891.html</link><description>仁者不忧，知者不惑，勇者不惧</description><language>zh-cn</language><lastBuildDate>Wed, 30 Apr 2014 08:34:42 GMT</lastBuildDate><pubDate>Wed, 30 Apr 2014 08:34:42 GMT</pubDate><ttl>60</ttl><item><title>Java 处理 xml BOM头</title><link>http://www.blogjava.net/JeromeKwok/articles/Java-xml-bom.html</link><dc:creator>Jerome Kwok</dc:creator><author>Jerome Kwok</author><pubDate>Mon, 28 Apr 2014 10:19:00 GMT</pubDate><guid>http://www.blogjava.net/JeromeKwok/articles/Java-xml-bom.html</guid><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp;只有注册用户登录后才能阅读该文。<a href='http://www.blogjava.net/JeromeKwok/articles/Java-xml-bom.html'>阅读全文</a><img src ="http://www.blogjava.net/JeromeKwok/aggbug/413016.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JeromeKwok/" target="_blank">Jerome Kwok</a> 2014-04-28 18:19 <a href="http://www.blogjava.net/JeromeKwok/articles/Java-xml-bom.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Java文件上传下载</title><link>http://www.blogjava.net/JeromeKwok/articles/386676.html</link><dc:creator>Jerome Kwok</dc:creator><author>Jerome Kwok</author><pubDate>Fri, 31 Aug 2012 03:37:00 GMT</pubDate><guid>http://www.blogjava.net/JeromeKwok/articles/386676.html</guid><wfw:comment>http://www.blogjava.net/JeromeKwok/comments/386676.html</wfw:comment><comments>http://www.blogjava.net/JeromeKwok/articles/386676.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/JeromeKwok/comments/commentRss/386676.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/JeromeKwok/services/trackbacks/386676.html</trackback:ping><description><![CDATA[<span style="font-family: Courier;"> </span><div>   <div id="content" mod-cs-content="" text-content=""  clearfix"=""> <p><span style="font-family: Courier;"></span></p><div><span style="font-family: Courier;">多文件上传的jsp页面，UpLoad.jsp</span><br />======================================================================</div><p>&nbsp;</p><p><span style="font-family: Courier;">&lt;%@ page language="java" import="java.util.*" pageEncoding="GBK"%&gt;</span><br /><span style="font-family: Courier;">&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;</span><br /><span style="font-family: Courier;">&lt;html&gt;</span><br /><span style="font-family: Courier;">&nbsp; &lt;head&gt;&nbsp;&nbsp;&nbsp; </span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &lt;title&gt;My JSP 'UpLoad.jsp' starting page&lt;/title&gt;</span><br /><span style="font-family: Courier;">&nbsp; &lt;/head&gt;</span><br />&nbsp; <br /><span style="font-family: Courier;">&nbsp; &lt;body&gt;</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &lt;form action="upLoad.do" enctype="MULTIPART/FORM-DATA" method=post name="fileForm"&gt;</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 请选择上传的文件:&lt;br/&gt;</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;input type="file" name="filename1"/&gt;</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;br/&gt;</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;input type="file" name="filename2"/&gt;</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;br/&gt;</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;input type="file" name="filename3"/&gt;</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;br/&gt;</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;input type="file" name="filename3"/&gt;</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;br/&gt;</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;input type="submit" value="开始上传"/&gt;</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &lt;/form&gt;</span><br /><span style="font-family: Courier;">&nbsp; &lt;/body&gt;</span><br /><span style="font-family: Courier;">&lt;/html&gt;</span><br /><span style="font-family: Courier;"></span><br /><span style="font-family: Courier;">多文件上传的FileUpload.java文件：</span></p><p>==========================================<br /><span style="font-family: Courier;">package load.up;</span><br /><span style="font-family: Courier;">import javax.servlet.http.HttpServletRequest;</span><br /><span style="font-family: Courier;">import java.io.File;</span><br /><span style="font-family: Courier;">import java.util.List;</span><br /><span style="font-family: Courier;">import java.util.Date;</span><br /><span style="font-family: Courier;">import java.util.Iterator;</span><br /><span style="font-family: Courier;">import org.apache.commons.fileupload.DiskFileUpload;</span><br /><span style="font-family: Courier;">import org.apache.commons.fileupload.FileItem;</span><br /><span style="font-family: Courier;">import org.apache.commons.fileupload.FileUploadException;</span><br /><span style="font-family: Courier;">import java.sql.Connection;</span><br /><span style="font-family: Courier;">import java.sql.DriverManager;</span><br /><span style="font-family: Courier;">import java.sql.SQLException;</span><br /><span style="font-family: Courier;">import java.sql.Statement;</span><br /><span style="font-family: Courier;">public class FileUpload {</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; /**</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;* 实现文件上传功能</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;* @param request HttpServletRequest</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;* @param tempPath 临时路径</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;* @param uploadPath 上传路径</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;* @param newFileName 新文件名称</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;* @return boolean 是否成功</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;*/</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; public boolean doFileUpload(HttpServletRequest request, String tempPath, String upLoadPath ,String newFileName, int msgId) {</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /** 成功上传 */</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; boolean flag=true;</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; try {</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /** 获取当前系统时间对象 */</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Date date = new Date();</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (!new File(upLoadPath).isDirectory())</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; new File(upLoadPath).mkdirs();</span><br /><span style="font-family: Courier;">//&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (!new File(tempPath).isDirectory())</span><br /><span style="font-family: Courier;">//&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; new File(tempPath).mkdirs();</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; DiskFileUpload diskFUpload = new DiskFileUpload();</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /** 设置Upload文件大小尺寸 */</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; diskFUpload.setSizeMax(5 * 1024 * 1024);</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /** 设置缓冲区大小 */</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; diskFUpload.setSizeThreshold(4 * 1024);</span><br /><span style="font-family: Courier;">//&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /** 设置临时存储路径 */</span><br /><span style="font-family: Courier;">//&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; diskFUpload.setRepositoryPath(tempPath);</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /** 得到所有上传文件List */</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; List fileItems = diskFUpload.parseRequest(request);</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /** 取得上传文件List迭代器 */</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Iterator it = fileItems.iterator();</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /** 遍历迭代器中的对象，进行对象处理 */</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; while (it.hasNext()) {</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /** 取得单个文件对象 */</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; FileItem fi = (FileItem) it.next();</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /** 获取上传文件文件名,包括文件路径 */</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String filePathName = fi.getName();</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String sysYear = date.getYear() + "";</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String sysMonth = date.getMonth() + "";</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String sysDay = date.getDay() + "";</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String sysHours = date.getHours() + "";</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String sysMin = date.getMinutes() + "";</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String sysSec = date.getSeconds() + "";</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; long sys=System.currentTimeMillis();</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /** 取当前系统时间 */</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String sysTime = sysYear + sysMonth + sysDay + sysHours</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; + sysMin + sysSec;</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /** 获取上传文件原文件名 */</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String fileOldName=filePathName.substring(filePathName.lastIndexOf("\\") + 1);</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /** 获取文件名，包括扩展名 */</span><br /><span style="font-family: Courier;">&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String fileName=sysTime+sys+fileOldName;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  </span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /** 上传文件服务器端保存路径 */</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String url=upLoadPath +"\\";</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /** 文件存在性check判断 */</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (fileName != null) {</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /** 服务器上保存上传文件 */</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fi.write(new File(url+fileName));</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /** 保存上传文件信息，更新TBL */</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; this.insertFileMsg(msgId, url, fileName, fileOldName);&nbsp;&nbsp;  </span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; flag = true;</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } else {</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; flag = false;</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } catch (Exception e) {</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; flag=false;</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return flag;</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; }</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; /**</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;* 更新TBL，保存上传文件相关信息</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;* @param msgId 用户ID</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;* @param fileUrl 服务器端上传文件保存路径</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;* @param fileName 服务器端保存上传文件的文件名</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;*/</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; private void insertFileMsg(int msgId,String fileUrl,String fileName,String fileOldName){</span><br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Connection conn=null;</span><br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /** 获取数据库链接Connection */</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; conn=this.getConn();</span><br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String sql = "insert into tfile(message_id,file_url,file_name,file_old_name) values("</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; + msgId</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; + ",'"</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; + fileUrl.replace("\\", "/")</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; + "','"</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; + fileName</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; + "','"</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; + fileOldName + "')";</span><br /><span style="font-family: Courier;">//&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; StringBuffer sb = new StringBuffer();</span><br /><span style="font-family: Courier;">//&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sb.append("insert into tfile(message_id,file_url) values(2)");</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.out.println(sql);</span><br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; try {</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Statement stmt=conn.createStatement();</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; stmt.execute(sql);</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } catch (SQLException e) {</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; e.printStackTrace();</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</span><br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.out.println(msgId+"::"+fileUrl+"::"+fileName);</span><br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; }</span><br />&nbsp;&nbsp;&nbsp; <br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; /**</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;* 获取数据库链接Connection</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;* @return 数据库链接Connection</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;*/</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; private Connection getConn(){</span><br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Connection conn=null;</span><br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String driver_class="com.mysql.jdbc.Driver";</span><br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String url="jdbc:mysql://192.168.1.19:3306/ctemdidb?useUnicode=true&amp;characterEncoding=utf8";</span><br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String userName="root";</span><br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String password="root123";</span><br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; try {</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Class.forName(driver_class);</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; conn=DriverManager.getConnection(url,userName,password);</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } catch (Exception e) {</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if(conn!=null){</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; try {</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; conn.close();</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } catch (SQLException e1) {</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; e1.printStackTrace();</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return conn;</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; }</span><br /><span style="font-family: Courier;">}</span><br /><span style="font-family: Courier;"></span><br /><span style="font-family: Courier;">下面是实现FileDownload的javaclass文件</span><br /><span style="font-family: Courier;">package load.down;</span><br /><br /><span style="font-family: Courier;">import java.sql.Connection;</span><br /><span style="font-family: Courier;">import java.sql.DriverManager;</span><br /><span style="font-family: Courier;">import java.sql.ResultSet;</span><br /><span style="font-family: Courier;">import java.sql.SQLException;</span><br /><span style="font-family: Courier;">import java.sql.Statement;</span><br /><span style="font-family: Courier;">import java.util.ArrayList;</span><br /><span style="font-family: Courier;">import java.util.List;</span><br /><span style="font-family: Courier;">import load.FileMsg;</span><br /><span style="font-family: Courier;">import javax.servlet.http.HttpServletRequest;</span><br /><span style="font-family: Courier;">import javax.servlet.http.HttpServletResponse;</span><br /><span style="font-family: Courier;">import java.io.File;</span><br /><span style="font-family: Courier;">import java.io.InputStream;</span><br /><span style="font-family: Courier;">import java.io.FileInputStream;</span><br /><span style="font-family: Courier;">import java.io.OutputStream;</span><br /><br /><span style="font-family: Courier;">public class FileDownload {</span><br /><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; public List getFileMsg(int msgId) {</span><br /><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; List fileMsglist = new ArrayList();</span><br /><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Connection conn = null;</span><br /><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; conn = this.getConn();</span><br /><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String sql = "select file_url,file_name,file_old_name from tfile where message_id="</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; + msgId;</span><br /><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; try {</span><br /><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Statement stmt = conn.createStatement();</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ResultSet rs = stmt.executeQuery(sql);</span><br /><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; while (rs.next()) {</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; FileMsg fileMsg = new FileMsg();</span><br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int messageId=rs.getInt("message_id");</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String fileUrl = rs.getString("file_url");</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String fileName = rs.getString("file_name");</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String fileOldName = rs.getString("file_old_name");</span><br /><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fileMsg.setMessageId(messageId);</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fileMsg.setFileUrl(fileUrl);</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fileMsg.setFileName(fileName);</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fileMsg.setFileOldName(fileOldName);</span><br /><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fileMsglist.add(fileMsg);</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } catch (SQLException e) {</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; e.printStackTrace();</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</span><br /><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return fileMsglist;</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; }</span><br /><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; /**</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;* 获取数据库链接Connection</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;* </span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;* @return 数据库链接Connection</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;*/</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; private Connection getConn() {</span><br /><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Connection conn = null;</span><br /><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String driver_class = "com.mysql.jdbc.Driver";</span><br /><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String url = "jdbc:mysql://192.168.1.19:3306/ctemdidb?useUnicode=true&amp;characterEncoding=utf8";</span><br /><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String userName = "root";</span><br /><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String password = "root123";</span><br /><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; try {</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Class.forName(driver_class);</span><br /><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; conn = DriverManager.getConnection(url, userName, password);</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } catch (Exception e) {</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return conn;</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; }</span><br /><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; /**</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;* download文件</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;* </span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;* @param request</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;* @param response</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;* @throws Exception</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;*/</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; public void doFileDownload(String path, String fileName,</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; HttpServletResponse response) throws Exception {</span><br /><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; File file = new File(path);</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; InputStream in = new FileInputStream(file);</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; OutputStream os = response.getOutputStream();</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; response.addHeader("Content-Disposition", "attachment;filename="</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; + fileName);</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; response.addHeader("Content-Length", file.length() + "");</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; response.setCharacterEncoding("utf-8");</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; response.setContentType("application/octet-stream");</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int data = 0;</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; while ((data = in.read()) != -1) {</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; os.write(data);</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; os.close();</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; in.close();</span><br /><span style="font-family: Courier;">&nbsp;&nbsp;&nbsp; }</span><br /><span style="font-family: Courier;">}</span><span style="font-family: Courier;"></span></p> </div></div><img src ="http://www.blogjava.net/JeromeKwok/aggbug/386676.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JeromeKwok/" target="_blank">Jerome Kwok</a> 2012-08-31 11:37 <a href="http://www.blogjava.net/JeromeKwok/articles/386676.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SSH框架下不使用第三方工具包实现文件上传、下载</title><link>http://www.blogjava.net/JeromeKwok/articles/386672.html</link><dc:creator>Jerome Kwok</dc:creator><author>Jerome Kwok</author><pubDate>Fri, 31 Aug 2012 03:30:00 GMT</pubDate><guid>http://www.blogjava.net/JeromeKwok/articles/386672.html</guid><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp;只有注册用户登录后才能阅读该文。<a href='http://www.blogjava.net/JeromeKwok/articles/386672.html'>阅读全文</a><img src ="http://www.blogjava.net/JeromeKwok/aggbug/386672.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JeromeKwok/" target="_blank">Jerome Kwok</a> 2012-08-31 11:30 <a href="http://www.blogjava.net/JeromeKwok/articles/386672.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Myeclipse 9.1 破解</title><link>http://www.blogjava.net/JeromeKwok/articles/365189.html</link><dc:creator>Jerome Kwok</dc:creator><author>Jerome Kwok</author><pubDate>Wed, 30 Nov 2011 04:05:00 GMT</pubDate><guid>http://www.blogjava.net/JeromeKwok/articles/365189.html</guid><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp;只有注册用户登录后才能阅读该文。<a href='http://www.blogjava.net/JeromeKwok/articles/365189.html'>阅读全文</a><img src ="http://www.blogjava.net/JeromeKwok/aggbug/365189.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JeromeKwok/" target="_blank">Jerome Kwok</a> 2011-11-30 12:05 <a href="http://www.blogjava.net/JeromeKwok/articles/365189.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>POI导出大量数据的简单解决方案(附源码) </title><link>http://www.blogjava.net/JeromeKwok/articles/365170.html</link><dc:creator>Jerome Kwok</dc:creator><author>Jerome Kwok</author><pubDate>Wed, 30 Nov 2011 02:23:00 GMT</pubDate><guid>http://www.blogjava.net/JeromeKwok/articles/365170.html</guid><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp;只有注册用户登录后才能阅读该文。<a href='http://www.blogjava.net/JeromeKwok/articles/365170.html'>阅读全文</a><img src ="http://www.blogjava.net/JeromeKwok/aggbug/365170.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JeromeKwok/" target="_blank">Jerome Kwok</a> 2011-11-30 10:23 <a href="http://www.blogjava.net/JeromeKwok/articles/365170.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>日志框架（一）----- log4j使用</title><link>http://www.blogjava.net/JeromeKwok/articles/365169.html</link><dc:creator>Jerome Kwok</dc:creator><author>Jerome Kwok</author><pubDate>Wed, 30 Nov 2011 02:18:00 GMT</pubDate><guid>http://www.blogjava.net/JeromeKwok/articles/365169.html</guid><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp;只有注册用户登录后才能阅读该文。<a href='http://www.blogjava.net/JeromeKwok/articles/365169.html'>阅读全文</a><img src ="http://www.blogjava.net/JeromeKwok/aggbug/365169.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JeromeKwok/" target="_blank">Jerome Kwok</a> 2011-11-30 10:18 <a href="http://www.blogjava.net/JeromeKwok/articles/365169.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>java模板模式与策略模式示例 </title><link>http://www.blogjava.net/JeromeKwok/articles/365165.html</link><dc:creator>Jerome Kwok</dc:creator><author>Jerome Kwok</author><pubDate>Wed, 30 Nov 2011 02:10:00 GMT</pubDate><guid>http://www.blogjava.net/JeromeKwok/articles/365165.html</guid><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp;只有注册用户登录后才能阅读该文。<a href='http://www.blogjava.net/JeromeKwok/articles/365165.html'>阅读全文</a><img src ="http://www.blogjava.net/JeromeKwok/aggbug/365165.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JeromeKwok/" target="_blank">Jerome Kwok</a> 2011-11-30 10:10 <a href="http://www.blogjava.net/JeromeKwok/articles/365165.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ANT-build.xml命令详解</title><link>http://www.blogjava.net/JeromeKwok/articles/365164.html</link><dc:creator>Jerome Kwok</dc:creator><author>Jerome Kwok</author><pubDate>Wed, 30 Nov 2011 02:08:00 GMT</pubDate><guid>http://www.blogjava.net/JeromeKwok/articles/365164.html</guid><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp;只有注册用户登录后才能阅读该文。<a href='http://www.blogjava.net/JeromeKwok/articles/365164.html'>阅读全文</a><img src ="http://www.blogjava.net/JeromeKwok/aggbug/365164.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JeromeKwok/" target="_blank">Jerome Kwok</a> 2011-11-30 10:08 <a href="http://www.blogjava.net/JeromeKwok/articles/365164.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JXL(JExcleApi)Excle详细使用心得(转)</title><link>http://www.blogjava.net/JeromeKwok/articles/365163.html</link><dc:creator>Jerome Kwok</dc:creator><author>Jerome Kwok</author><pubDate>Wed, 30 Nov 2011 02:05:00 GMT</pubDate><guid>http://www.blogjava.net/JeromeKwok/articles/365163.html</guid><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp;只有注册用户登录后才能阅读该文。<a href='http://www.blogjava.net/JeromeKwok/articles/365163.html'>阅读全文</a><img src ="http://www.blogjava.net/JeromeKwok/aggbug/365163.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JeromeKwok/" target="_blank">Jerome Kwok</a> 2011-11-30 10:05 <a href="http://www.blogjava.net/JeromeKwok/articles/365163.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ICON图标下载地址汇总</title><link>http://www.blogjava.net/JeromeKwok/articles/322638.html</link><dc:creator>Jerome Kwok</dc:creator><author>Jerome Kwok</author><pubDate>Thu, 03 Jun 2010 08:53:00 GMT</pubDate><guid>http://www.blogjava.net/JeromeKwok/articles/322638.html</guid><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp;只有注册用户登录后才能阅读该文。<a href='http://www.blogjava.net/JeromeKwok/articles/322638.html'>阅读全文</a><img src ="http://www.blogjava.net/JeromeKwok/aggbug/322638.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JeromeKwok/" target="_blank">Jerome Kwok</a> 2010-06-03 16:53 <a href="http://www.blogjava.net/JeromeKwok/articles/322638.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Java验证码</title><link>http://www.blogjava.net/JeromeKwok/articles/304336.html</link><dc:creator>Jerome Kwok</dc:creator><author>Jerome Kwok</author><pubDate>Tue, 01 Dec 2009 01:37:00 GMT</pubDate><guid>http://www.blogjava.net/JeromeKwok/articles/304336.html</guid><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp;只有注册用户登录后才能阅读该文。<a href='http://www.blogjava.net/JeromeKwok/articles/304336.html'>阅读全文</a><img src ="http://www.blogjava.net/JeromeKwok/aggbug/304336.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JeromeKwok/" target="_blank">Jerome Kwok</a> 2009-12-01 09:37 <a href="http://www.blogjava.net/JeromeKwok/articles/304336.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JSTL核心库使用详解</title><link>http://www.blogjava.net/JeromeKwok/articles/233396.html</link><dc:creator>Jerome Kwok</dc:creator><author>Jerome Kwok</author><pubDate>Thu, 09 Oct 2008 09:33:00 GMT</pubDate><guid>http://www.blogjava.net/JeromeKwok/articles/233396.html</guid><wfw:comment>http://www.blogjava.net/JeromeKwok/comments/233396.html</wfw:comment><comments>http://www.blogjava.net/JeromeKwok/articles/233396.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/JeromeKwok/comments/commentRss/233396.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/JeromeKwok/services/trackbacks/233396.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 关键词：Java 标准标签库（&nbsp;Java Standard Tag Libraries, JSTL）1 JSTL概述JSTL是著名开源项目Jakarta Taglibs Project（http://jakarta.apache.org/taglibs/index.html）的研究成果，JSTL为JSP页面开发者提供了最通用的标签。功能主要包括通用编程逻辑封装、数据库相关操作、X...&nbsp;&nbsp;<a href='http://www.blogjava.net/JeromeKwok/articles/233396.html'>阅读全文</a><img src ="http://www.blogjava.net/JeromeKwok/aggbug/233396.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JeromeKwok/" target="_blank">Jerome Kwok</a> 2008-10-09 17:33 <a href="http://www.blogjava.net/JeromeKwok/articles/233396.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>分享两个简单的页面开发技巧</title><link>http://www.blogjava.net/JeromeKwok/articles/232835.html</link><dc:creator>Jerome Kwok</dc:creator><author>Jerome Kwok</author><pubDate>Tue, 07 Oct 2008 02:03:00 GMT</pubDate><guid>http://www.blogjava.net/JeromeKwok/articles/232835.html</guid><wfw:comment>http://www.blogjava.net/JeromeKwok/comments/232835.html</wfw:comment><comments>http://www.blogjava.net/JeromeKwok/articles/232835.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/JeromeKwok/comments/commentRss/232835.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/JeromeKwok/services/trackbacks/232835.html</trackback:ping><description><![CDATA[<div class="postTitle"><span style="font-size: 10pt; font-family: Courier">1.td的折断换行显示<br />
比如现在有&lt;td style="width:30px"&gt;abcdabcdabcdabcdabcd&lt;/td&gt;，由于是英文，是不会自动折断换行的。当然你强制的写成&lt;td style="width:30px"&gt;abcdabc&lt;/br&gt;dabcdabcdabcd&lt;/td&gt;的话&#8230;&#8230;<br />
这时候，你就需要word-wrap:break-word;word-break:break-all;<br />
<div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><img alt="" src="http://www.blogjava.net/Images/OutliningIndicators/None.gif" align="top" /><span style="color: #0000ff">&lt;</span><span style="color: #800000">td&nbsp;</span><span style="color: #ff0000">style</span><span style="color: #0000ff">="width:30px;word-wrap:break-word;word-break:break-all;"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000">abcdabcdabcdabcdabcd</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">td</span><span style="color: #0000ff">&gt;</span></div>
搞定。<br />
<br />
2.table的row颜色交替显示<br />
这个有很多方法，用js控制，css控制，很多很多方法，google一下一大把。我常用的就是一句话：<br />
<div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><img id="Codehighlighter1_15_105_Open_Image" onclick="this.style.display='none'; Codehighlighter1_15_105_Open_Text.style.display='none'; Codehighlighter1_15_105_Closed_Image.style.display='inline'; Codehighlighter1_15_105_Closed_Text.style.display='inline';" alt="" src="http://www.blogjava.net/Images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_15_105_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_15_105_Closed_Text.style.display='none'; Codehighlighter1_15_105_Open_Image.style.display='inline'; Codehighlighter1_15_105_Open_Text.style.display='inline';" alt="" src="http://www.blogjava.net/Images/OutliningIndicators/ContractedBlock.gif" align="top" /><span style="color: #800000">TABLE.result&nbsp;TR</span><span id="Codehighlighter1_15_105_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff">{<img alt="" src="http://www.blogjava.net/Images/dot.gif" />}</span><span id="Codehighlighter1_15_105_Open_Text"><span style="color: #000000">{</span><span style="color: #ff0000">background-color</span><span style="color: #000000">:</span><span style="color: #0000ff">expression((this.sectionRowIndex%2==0)?"#B1D7E3":"#E3F2FE")</span><span style="color: #000000">;</span><span style="color: #ff0000">height</span><span style="color: #000000">:</span><span style="color: #0000ff">23px</span><span style="color: #000000">;</span><span style="color: #000000">}</span></span></div>
指定table的class即可。</span></div>
<img src ="http://www.blogjava.net/JeromeKwok/aggbug/232835.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JeromeKwok/" target="_blank">Jerome Kwok</a> 2008-10-07 10:03 <a href="http://www.blogjava.net/JeromeKwok/articles/232835.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>