CKEDITOR.editorConfig = function( config ) {
调用的action方法
config.filebrowserUploadUrl = 'vmscms/UpFj.action';
禁止标签选项卡
config.removeDialogTabs = 'link:advanced;link:target;image:Upload;image:target;flash:Upload;flash:target;';
config.toolbar = 'Full'; config.toolbarStartupExpanded = false; config.width='580px'; config.height='250px';
//默认工具栏 高级
config.toolbar_Full = [
{ name: 'document', items : [
'Source','-','NewPage','DocProps','Preview','Print','-','Templates' ] },
{ name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] },
{ name: 'editing', items : [ 'Find','Replace','-','SelectAll','-','SpellChecker', 'Scayt' ] },'/',
{ name: 'forms', items : [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField' ] },
{ name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] },
{ name: 'links', items : [ 'Link','Unlink','Anchor' ] },
{ name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote','CreateDiv', '-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl' ] },
{ name: 'insert', items : [ 'Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe' ] }, '/',
{ name: 'styles', items : [ 'Styles','Format','Font','FontSize' ] },
{ name: 'colors', items : [ 'TextColor','BGColor' ] },
{ name: 'tools', items : [ 'Maximize', 'ShowBlocks','-','About' ] } ];
};
配置上面的后 点击编辑器插入超链接
public String UpFj() {
PrintWriter out = null;
HttpServletResponse response = ServletActionContext.getResponse();
response.setContentType("text/html;charset=utf-8");
response.setCharacterEncoding("utf-8");
try {
out = response.getWriter();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
// 文件上传
if (upload != null) {
String up =
uploadFileName.substring(uploadFileName.lastIndexOf("."));
// 判断附件的格式
/* if (up.equalsIgnoreCase(".wps")) {
out.print("该功能不支持上传.wps");
return null; }*/
// 按照日期每天生成一个文件夹
String path = "/upload/cms/"
+ new SimpleDateFormat("yyyyMMdd").format(new Date());
// 判断文件夹是否存在
File destFile = new File(ServletActionContext.getServletContext()
.getRealPath("")
+ path);
if (!destFile.exists()) {
destFile.mkdir();
}
path = path + "/" + uploadFileName;
try {
FileUtils.copyFile(upload, new File(ServletActionContext
.getServletContext().getRealPath("")
+ path));
pathvalue = path.substring(1);
out.print(pathvalue);
} catch (IOException e) {
e.printStackTrace();
}finally {
out.flush();
out.close();
}
}
return null;
}
在测试中 后台接收时只能用 upload 属性 wps上传过后在前台点击不支持下载和保存,直接打开后乱码!!