支持中文的 jspSmartUpload.jar包
2009-12-27 19:41
295 查看
下载:
/Files/hijackwust/jsmartcom_zh_CN.rar
-----------------------------------------------
jsp页面:
<%@ page contentType="text/html;charset=GBK"%>
<html>
<head>
<title>File Upload</title>
</head>
<body>
<font size=5 color=#FF0000> <b>文件上传----使用jspsmart upload组件</b> </font>
<br>
<form action="uploadfile" method="post" enctype="multipart/form-data">
<p>文件名称: <input type="file" name="file1" size="20" maxlength="80">
</p>
<p>文件名称: <input type="file" name="file2" size="20" maxlength="80">
</p>
<p>文件名称: <input type="file" name="file3" size="20" maxlength="80">
</p>
<p>上传路径: <input type="text" name="path" size="30" maxlength="50"><br>
</p>
<p>附加内容: <input type="text" name="other" size="30" maxlength="50">
</p>
<p><input type="submit" value="上传"> <input type="reset"
value="重置"></p>
</form>
<font size=5 color=#FF0000> <b>文件下载----使用jspsmart upload组件</b> </font>
<br>
<form action="downloadfile" method="post">
<p>下载文件的名称: <input type="text" name="downloadFileName" size="20"
maxlength="80"></p>
<input type="submit" value="下载">
</body>
</form>
</html>
两个Servlet: ServletUpload 和ServletDownload
public class ServletUpload extends HttpServlet {
private ServletConfig config;
final public void init(ServletConfig config) throws ServletException {
this.config = config;
}
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
PrintWriter out = response.getWriter();
out.println("<HTML>");
out.println("<BODY BGCOLOR='white'>");
out.println("<H1>jspSmartUpload : Servlet Sample</H1>");
out.println("<HR>");
// 变量定义
int count = 0;
SmartUpload mySmartUpload = new SmartUpload();
try {
mySmartUpload.initialize(config, request, response);
mySmartUpload.upload();
for (int i = 0; i < mySmartUpload.getFiles().getCount(); i++) {
com.jspsmart.upload.File myfile = mySmartUpload.getFiles().getFile(i);
String fileName = myfile.getFileName();
count = mySmartUpload.save("/upload");
//count = mySmartUpload.save(null);
}
out.println(count + " file uploaded.");
} catch (Exception e) {
out.println("Unable to upload the file.<br>");
out.println("Error : " + e.toString());
}
out.println("</BODY>");
out.println("</HTML>");
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
public class ServletDownload extends HttpServlet {
private ServletConfig config;
final public void init(ServletConfig config) throws ServletException {
this.config = config;
}
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String temp_p =request.getParameter("downloadFileName");
byte[] temp_t=temp_p.getBytes("ISO8859_1");
String fileName=new String(temp_t,"GBK");
SmartUpload mySmartUpload = new SmartUpload();
try {
mySmartUpload.initialize(config, request, response);
mySmartUpload.setContentDisposition(null);
mySmartUpload.downloadFile("/upload/"+fileName);
} catch (Exception e) {
e.printStackTrace();
}
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
/Files/hijackwust/jsmartcom_zh_CN.rar
-----------------------------------------------
jsp页面:
<%@ page contentType="text/html;charset=GBK"%>
<html>
<head>
<title>File Upload</title>
</head>
<body>
<font size=5 color=#FF0000> <b>文件上传----使用jspsmart upload组件</b> </font>
<br>
<form action="uploadfile" method="post" enctype="multipart/form-data">
<p>文件名称: <input type="file" name="file1" size="20" maxlength="80">
</p>
<p>文件名称: <input type="file" name="file2" size="20" maxlength="80">
</p>
<p>文件名称: <input type="file" name="file3" size="20" maxlength="80">
</p>
<p>上传路径: <input type="text" name="path" size="30" maxlength="50"><br>
</p>
<p>附加内容: <input type="text" name="other" size="30" maxlength="50">
</p>
<p><input type="submit" value="上传"> <input type="reset"
value="重置"></p>
</form>
<font size=5 color=#FF0000> <b>文件下载----使用jspsmart upload组件</b> </font>
<br>
<form action="downloadfile" method="post">
<p>下载文件的名称: <input type="text" name="downloadFileName" size="20"
maxlength="80"></p>
<input type="submit" value="下载">
</body>
</form>
</html>
两个Servlet: ServletUpload 和ServletDownload
public class ServletUpload extends HttpServlet {
private ServletConfig config;
final public void init(ServletConfig config) throws ServletException {
this.config = config;
}
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
PrintWriter out = response.getWriter();
out.println("<HTML>");
out.println("<BODY BGCOLOR='white'>");
out.println("<H1>jspSmartUpload : Servlet Sample</H1>");
out.println("<HR>");
// 变量定义
int count = 0;
SmartUpload mySmartUpload = new SmartUpload();
try {
mySmartUpload.initialize(config, request, response);
mySmartUpload.upload();
for (int i = 0; i < mySmartUpload.getFiles().getCount(); i++) {
com.jspsmart.upload.File myfile = mySmartUpload.getFiles().getFile(i);
String fileName = myfile.getFileName();
count = mySmartUpload.save("/upload");
//count = mySmartUpload.save(null);
}
out.println(count + " file uploaded.");
} catch (Exception e) {
out.println("Unable to upload the file.<br>");
out.println("Error : " + e.toString());
}
out.println("</BODY>");
out.println("</HTML>");
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
public class ServletDownload extends HttpServlet {
private ServletConfig config;
final public void init(ServletConfig config) throws ServletException {
this.config = config;
}
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String temp_p =request.getParameter("downloadFileName");
byte[] temp_t=temp_p.getBytes("ISO8859_1");
String fileName=new String(temp_t,"GBK");
SmartUpload mySmartUpload = new SmartUpload();
try {
mySmartUpload.initialize(config, request, response);
mySmartUpload.setContentDisposition(null);
mySmartUpload.downloadFile("/upload/"+fileName);
} catch (Exception e) {
e.printStackTrace();
}
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
相关文章推荐
- 【下载】支持中文的 jspSmartUpload jar 包
- jspSmartUpload上传下载全攻略(支持中文下载)- -
- 今天使用jspsmartupload.jar实现上传文件的功能,发现中文乱码,于是总结了下解决方法
- [JAVA]支持中文参数的 jspSmartUpload
- SmartUpload控件 中文乱码问题 jsp+servlet解决办法
- jspSmartUpload.jar下载 转:虚竹之屋
- jsp SmartUpload 中文乱码问题解决
- jspsmartupload上传文件中文乱码
- jspsmartupload上传文件,中文乱码解决方法
- jspSmartUpload上传中文乱码问题
- 关于使用jspsmartupload.jar进行文件的上传与下载
- 多表单提交 - 再谈JSP使用SmartUpload组件上传的中文问题
- 谁 有 支 持 中 文 的 jspsmartupload.jar ?
- jspsmartupload中文帮助文档
- jspSmartUpload实现上传下载时的中文乱码问题
- 关于jspsmartupload 中文各种乱码的解决方法
- JspSmartUpload上传中文时出现乱码的解决方法
- JSP 文件 下载 代码 (不使用 jsp smart upload 组件) 解决中文名 问题
- Java Web中使用JSPSmartUpload控件实现文件的上传和下载(解决了中文乱码问题)(JSP页面采用GBK编码)
- jspsmart实现文件上传下载及jspSmartUpload.jar下载