资源简介
富文本编辑器demo,java 实现,可把数据存入数据库,在jsp中修改数据库配置

代码片段和文件信息
package ueditor;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*;
import org.apache.commons.fileupload.*;
import org.apache.commons.fileupload.FileUploadbase.InvalidContentTypeException;
import org.apache.commons.fileupload.FileUploadbase.SizeLimitExceededException;
import org.apache.commons.fileupload.util.*;
import org.apache.commons.fileupload.servlet.*;
import org.apache.commons.fileupload.FileItemIterator;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import sun.misc.base64Decoder;
import javax.servlet.http.HttpServletRequest;
/**
* UEditor文件上传辅助类
*
*/
public class Uploader {
// 输出文件地址
private String url = ““;
// 上传文件名
private String fileName = ““;
// 状态
private String state = ““;
// 文件类型
private String type = ““;
// 原始文件名
private String originalName = ““;
// 文件大小
private String size = ““;
private HttpServletRequest request = null;
private String title = ““;
// 保存路径
private String savePath = “upload“;
// 文件允许格式
private String[] allowFiles = { “.rar“ “.doc“ “.docx“ “.zip“ “.pdf““.txt“ “.swf“ “.wmv“ “.gif“ “.png“ “.jpg“ “.jpeg“ “.bmp“ };
// 文件大小限制,单位KB
private int maxSize = 10000;
private HashMap errorInfo = new HashMap();
public Uploader(HttpServletRequest request) {
this.request = request;
HashMap tmp = this.errorInfo;
tmp.put(“SUCCESS“ “SUCCESS“); //默认成功
tmp.put(“NOFILE“ “未包含文件上传域“);
tmp.put(“TYPE“ “不允许的文件格式“);
tmp.put(“SIZE“ “文件大小超出限制“);
tmp.put(“ENTYPE“ “请求类型ENTYPE错误“);
tmp.put(“REQUEST“ “上传请求异常“);
tmp.put(“IO“ “IO异常“);
tmp.put(“DIR“ “目录创建失败“);
tmp.put(“UNKNOWN“ “未知错误“);
}
public void upload() throws Exception {
boolean isMultipart = ServletFileUpload.isMultipartContent(this.request);
if (!isMultipart) {
this.state = this.errorInfo.get(“NOFILE“);
return;
}
DiskFileItemFactory dff = new DiskFileItemFactory();
String savePath = this.getFolder(this.savePath);
dff.setRepository(new File(savePath));
try {
ServletFileUpload sfu = new ServletFileUpload(dff);
sfu.setSizeMax(this.maxSize * 1024);
sfu.setHeaderEncoding(“utf-8“);
FileItemIterator fii = sfu.getItemIterator(this.request);
while (fii.hasNext()) {
FileItemStream fis = fii.next();
if (!fis.isFormField()) {
this.originalName = fis.getName().substring(fis.getName().lastIndexOf(System.getProperty(“file.separator“)) + 1);
if (!this.checkFileType(this.originalName)) {
this.state = this.errorInfo.get(“TYPE“);
continue;
}
this.fileName = this.getName(this.originalName);
this.type = this.getFileExt(this.fileName);
this.url = savePath + “/“ + this.fileName;
BufferedInputStream in = new BufferedInputStream(fis.openStream());
FileOutputStream out = new FileOutputStream(new File(this.getPhysicalPath(this.url)));
BufferedOutputStream output = new Bu
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 608 2014-07-21 16:03 EditorMe\.classpath
文件 297 2014-07-21 16:03 EditorMe\.myme
文件 1281 2014-07-21 16:15 EditorMe\.project
文件 105 2014-07-21 16:15 EditorMe\.settings\com.genuitec.eclipse.core.prefs
文件 88 2014-07-21 16:08 EditorMe\.settings\org.eclipse.core.resources.prefs
文件 83 2014-07-21 16:08 EditorMe\.settings\org.eclipse.core.runtime.prefs
文件 7377 2014-07-21 16:05 EditorMe\src\ueditor\Uploader.java
文件 1272 2014-07-21 16:24 EditorMe\WebRoot\index.jsp
文件 36 2014-07-21 16:03 EditorMe\WebRoot\me
文件 3374 2014-07-21 17:05 EditorMe\WebRoot\save.jsp
文件 1627 2013-06-25 14:17 EditorMe\WebRoot\ueditor\dialogs\anchor\anchor.html
文件 2602 2013-06-25 14:17 EditorMe\WebRoot\ueditor\dialogs\attachment\attachment.css
文件 6241 2013-06-25 14:17 EditorMe\WebRoot\ueditor\dialogs\attachment\attachment.html
文件 6009 2013-06-25 14:17 EditorMe\WebRoot\ueditor\dialogs\attachment\callbacks.js
文件 923 2013-06-25 14:17 EditorMe\WebRoot\ueditor\dialogs\attachment\fileTypeImages\icon_chm.gif
文件 841 2013-06-25 14:17 EditorMe\WebRoot\ueditor\dialogs\attachment\fileTypeImages\icon_default.png
文件 1012 2013-06-25 14:17 EditorMe\WebRoot\ueditor\dialogs\attachment\fileTypeImages\icon_doc.gif
文件 949 2013-06-25 14:17 EditorMe\WebRoot\ueditor\dialogs\attachment\fileTypeImages\icon_exe.gif
文件 986 2013-06-25 14:17 EditorMe\WebRoot\ueditor\dialogs\attachment\fileTypeImages\icon_mp3.gif
文件 1001 2013-06-25 14:17 EditorMe\WebRoot\ueditor\dialogs\attachment\fileTypeImages\icon_mv.gif
文件 996 2013-06-25 14:17 EditorMe\WebRoot\ueditor\dialogs\attachment\fileTypeImages\icon_pdf.gif
文件 1001 2013-06-25 14:17 EditorMe\WebRoot\ueditor\dialogs\attachment\fileTypeImages\icon_ppt.gif
文件 1009 2013-06-25 14:17 EditorMe\WebRoot\ueditor\dialogs\attachment\fileTypeImages\icon_psd.gif
文件 1007 2013-06-25 14:17 EditorMe\WebRoot\ueditor\dialogs\attachment\fileTypeImages\icon_rar.gif
文件 970 2013-06-25 14:17 EditorMe\WebRoot\ueditor\dialogs\attachment\fileTypeImages\icon_txt.gif
文件 1005 2013-06-25 14:17 EditorMe\WebRoot\ueditor\dialogs\attachment\fileTypeImages\icon_xls.gif
文件 747 2013-06-25 14:17 EditorMe\WebRoot\ueditor\dialogs\attachment\fileTypeMaps.js
文件 1102 2013-06-25 14:17 EditorMe\WebRoot\ueditor\dialogs\background\background.css
文件 2891 2013-06-25 14:17 EditorMe\WebRoot\ueditor\dialogs\background\background.html
文件 11945 2013-06-25 14:17 EditorMe\WebRoot\ueditor\dialogs\background\background.js
............此处省略227个文件信息
- 上一篇:毕向东老师35天基础java全部源代码
- 下一篇:android 象棋
相关资源
- java 毕业设计 进销存管理系统 源码
- java图片浏览器跨平台运行程序与源码
- 基于java的在线考试系统-毕业设计
- 微博系统(Java源码,servlet+jsp),适
- java串口通信全套完整代码-导入eclip
- jsonarray所必需的6个jar包.rar
- 三角网构TIN生成算法,Java语言实现
- java代码编写将excel数据导入到mysql数据
- Java写的cmm词法分析器源代码及javacc学
- JAVA JSP公司财务管理系统 源代码 论文
- JSP+MYSQL旅行社管理信息系统
- 推荐算法的JAVA实现
- 基于Java的酒店管理系统源码(毕业设
- java-图片识别 图片比较
- android毕业设计
- java23种设计模式+23个实例demo
- java Socket发送/接受报文
- JAVA828436
- java界面美化 提供多套皮肤直接使用
- 在线聊天系统(java代码)
- 基于Java的图书管理系统807185
- java中实现将页面数据导入Excel中
- java 企业销售管理系统
- java做的聊天系统(包括正规课程设计
- Java编写的qq聊天室
- 商店商品管理系统 JAVA写的 有界面
- JAVA开发聊天室程序
- 在linux系统下用java执行系统命令实例
- java期末考试试题两套(答案) 选择(
- JAVA3D编程示例(建模、交互)
评论
共有 条评论