ckeditor

使用三部曲

1.下载

2.引入

3.使用

<!-- 引入ckeditor的类库 -->
<script src="../ckeditor/ckeditor.js"></script>

<p>
        <label> 内容 </label>
        <textarea name="ncontent" id="nr" cols="70" rows="10"></textarea>
          <script>
              CKEDITOR.replace('ncontent');
          </script>
      </p>

smartupload

表单必须用enctype属性进行封装:
    <form action="" method="post" enctype="multipart/form-data">
    //表示表单将按照二进制的方式提交

在使用smartUpload时必须严格按照如上程序进行:
    SmartUpload smart=new SmartUpload();  //实例化SmartUpload上传组件
    smart.initialize(pageContext);    //初始化上传操作
    smart.upload();        //上传准备
    smart.save("upload");    //将上传文件保存在upload文件夹中

当一个表单使用了enctype封装后,其他的非文件类的表单控件的内容就无法通过request内置对象取得,此时必须通过SmartUpload类中提供的getRequest()方法取得全部的请求参数。

String uname=smart.getRequest().getParameter("uname");
    注意:该句代码一定要在执行完upload()方法之后才可以使用

案例

<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body><form action="doindex.jsp" enctype="multipart/form-data" method="post">头像:<input type="file" multiple="multiple" name="ifile"><br>用户名:<input type="text" name="iname" ><br><input type="submit" value="注册"><input type="reset" value="清空"></form>
</body>
</html>
<%@page import="com.jspsmart.upload.Files"%>
<%@page import="com.jspsmart.upload.Request"%>
<%@page import="com.jspsmart.upload.File"%>
<%@page import="com.jspsmart.upload.SmartUpload"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%>
<%//问题:请问客户端的文件到底要上传到哪里//A:放到数据库里 × 把其在服务器硬盘文件夹的路劲保存到数据库里//B:放到服务器硬盘的某个指定文件夹 √//一、单文件上传//实例化SmartUpload su=new SmartUpload();//初始化 pageContext是jsp的九大内置对象之一 作用域仅限于当前的jsp页面su.initialize(pageContext);//设置相关要求su.setCharset("utf-8");su.setAllowedFilesList("jpg,png,jpeg,gif");//设置允许上传的文件类型 用逗号隔开su.setDeniedFilesList("exe,jsp,js,bat");//设置禁止上传的文件类型su.setMaxFileSize(1024*1024*10);//设置文件的最大大小 不超过10M//上传到服务器内存su.upload();/* //--自动找web项目的跟目录String path="images/";//获取文件File file=su.getFiles().getFile(0);if(!file.isMissing()){//上传了文件//设置文件的编码方式file.setCharset("utf-8");path+=file.getFileName();//拼接上原有的文件名file.saveAs(path,SmartUpload.SAVE_VIRTUAL);}out.print(path); *//* //--手动找web项目的跟目录String path="images/";String webPath=this.getServletContext().getRealPath("/");//获取文件File file=su.getFiles().getFile(0);if(!file.isMissing()){//上传了文件//设置文件的编码方式file.setCharset("utf-8");path+=file.getFileName();//拼接上原有的文件名file.saveAs(webPath+path);//手动找web项目的根目录}out.print(path); *///不管哪种方式 只需要把path对应列/* //拿表单的其他值  建议放在文件上传之后Request req=su.getRequest();String name=req.getParameter("iname");out.print(name); *///二、多文件上传//拿到所有的文件Files fs=su.getFiles();//拿到总数目//out.print(fs.getCount());for(int i=0;i<fs.getCount();i++){//依次拿到每一个文件 依次进行上传File file=fs.getFile(i);String path="images/";if(!file.isMissing()){//上传了文件//设置文件的编码方式file.setCharset("utf-8");path+=file.getFileName();//拼接上原有的文件名file.saveAs(path,SmartUpload.SAVE_VIRTUAL);}out.print(path+"<br>");}%>

ckeditorsmartupload相关推荐

  1. javaWeb10(ckeditorsmartupload)

    一.ckeditor 这是一个富文本器,能够更好的帮助我们的项目友好型,当然除了这个富文本器以外还有其他的.比如: 1.Kindeditor 2.ueditor 3.wangEditor 4.Smar ...

  2. javawe(ckeditorsmartupload)

    铁汁们今天接着来分享JavaWeb的ckeditor&smartup 一.什么是session内置对象: session也可以称为:会话,它是jsp的常用内置对象之一: 1.1 什么是会话? ...

  3. 常用插件:分享12款超级好用的 Chrome 插件

    1.dblock Plus:免除广告困扰 你是不是每次搜索百度前几个都是广告?有了它,你的搜索结果只有纯净. 2. 监听网络请求插件 simple-extension插件让每个网站都可以保存/切换Co ...

最新文章

  1. 搞事情 -- python之线程
  2. 201621123075作业12-流与文件
  3. 如何评估一项技术是否值得长期投入?
  4. python tk下拉列表的state_Python tkinter之ComboBox(下拉框)的使用简介
  5. Python自定义函数的创建、调用和函数的参数详解
  6. centos7 安装 mysql5.7
  7. Eclipse中配置Tomcat虚拟路径
  8. linux 提升cpu权限,CPUlimit有效防止Linux系统CPU过载
  9. phoenix的元数据一般存在哪里_Phoenix的一些问题
  10. 最适合物联网的开源数据库
  11. win8+sdk8+vs2012+freeglut+glew开发opengl
  12. wps可以登录网页版_教程丨WPS会员半自动打卡
  13. hdu 1284 钱币兑换问题
  14. 《软件需求十步走》阅读笔记一
  15. mysql public权限_MySQL · 引擎特性 · Binlog encryption 浅析
  16. 8.程序员的自我修养---动态链接
  17. jmeter录制脚本(针对谷歌)
  18. 社会工程学——基础认知(补充)
  19. C语言apr_socket,APR分析-高级IO篇
  20. css3中vw/vh/vmin/vmax的含义与使用方法

热门文章

  1. linux解压war包后删除war包,解压好的文件夹跟着消失
  2. 阿里云AI平台NLP使用
  3. freebsd安装xfce桌面
  4. 忽略了导热硅脂等于祸害电脑
  5. W3school离线手册2019资源下载
  6. 2021-2027全球及中国WiFi热点软件行业研究及十四五规划分析报告
  7. 消息钩子与定时器(VC_Win32)
  8. QT程序按钮效果制作
  9. svn文件图标不显示-解决方案
  10. win7备份工具_利用大白菜U盘启动工具制作系统安装工具,小白学会就成高手了