富文本ckediter
##<link rel='stylesheet' href='/css/index.css' />
<script type="text/javascript" src="/ckeditor/ckeditor.js"></script>
<textarea name="editor1" id="editor1" rows="10" cols="80">
</textarea>
<div style="margin-top:3rem;">
消息标题:<input type="text" id="ctitle" style="width:500px;"/>
<input type="button" id="button1" value="提交" style="height:2.5rem;width:100%;font-size:1.2rem;letter-spacing:3rem;"/>
</div>
<script type="text/javascript">
$(function(){
CKEDITOR.replace( 'editor1', {
filebrowserUploadUrl: '$!{base}/haliluya/uploadimg.html'
});
$("#button1").click(function(){
var editor = CKEDITOR.instances.editor1;
$.ajax({
url : "/haliluya/uploadContent.html",
data : {
'editorData' : editor.getData(),
'ctitle' : $("#ctitle").val()
},
type : "POST",
success : function(result) {
if (result) {
alert("保存成功");
}else{
alert("提交失败");
}
},
error : function(request) {
alert("sorry!");
}
}, "json");
});
});
</script>
package shareAction;
import java.io.File;
import java.io.PrintWriter;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import shareMode.GoodNews;
import shareService.GoodNewsService;
@Controller
@RequestMapping({"/haliluya"})
public class Halelujah
{
@Autowired
private GoodNewsService goodNewsService;
@RequestMapping({"/uploadContent"})
@ResponseBody
public boolean uploadContent(String editorData, String ctitle)
{
boolean ok = true;
GoodNews goodNews = new GoodNews();
goodNews.setContent(editorData);
goodNews.setCtitle(ctitle);
int insert = this.goodNewsService.insertGoodNewsService(goodNews);
if (insert <= 0) {
ok = false;
}
return ok;
}
@RequestMapping({"/uploadimg"})
public void execute(HttpServletResponse response, MultipartHttpServletRequest multipartHttpServletRequest, HttpServletRequest httpServletRequest)
throws Exception
{
MultipartFile file = multipartHttpServletRequest.getFile("upload");
String filename = file.getOriginalFilename();
String imgtype = filename.substring(filename.lastIndexOf("."));
String localhostUrl = "images/contentImg/";
String ctxPath = multipartHttpServletRequest.getSession().getServletContext().getRealPath("/") + localhostUrl;
File dirPath = new File(ctxPath);
if (!dirPath.exists()) {
dirPath.mkdir();
}
filename = String.valueOf(Math.random()) + imgtype;
File uploadFile = new File(ctxPath + filename);
FileCopyUtils.copy(file.getBytes(), uploadFile);
String URL = httpServletRequest.getScheme() + "://" + httpServletRequest.getServerName() + ":" + httpServletRequest.getServerPort() + httpServletRequest.getContextPath() + "/";
String callbackUrl = URL + localhostUrl + filename;
String callback = httpServletRequest.getParameter("CKEditorFuncNum");
PrintWriter out = response.getWriter();
out.println("<script type=\"text/javascript\">");
out.println("window.parent.CKEDITOR.tools.callFunction(" + callback + ",'" + callbackUrl + "','')");
out.println("</script>");
}
@RequestMapping({"/uploadNews"})
public String uploadNews()
{
return "/b/uploadNews";
}
}
富文本ckediter的更多相关文章
- 富文本编辑器Simditor的简易使用
最近打算自己做一个博客系统,并不打算使用帝国cms或者wordpress之类的做后台管理!自己处于学习阶段也就想把从前台到后台一起谢了.好了,废话不多说了,先来看看富文本编辑器SimDitor,这里是 ...
- 个人网站对xss跨站脚本攻击(重点是富文本编辑器情况)和sql注入攻击的防范
昨天本博客受到了xss跨站脚本注入攻击,3分钟攻陷--其实攻击者进攻的手法很简单,没啥技术含量.只能感叹自己之前竟然完全没防范. 这是数据库里留下的一些记录.最后那人弄了一个无限循环弹出框的脚本,估计 ...
- 图解DevExpress RichEditControl富文本的使用,附源码及官方API
9点半了,刚写到1.2. 该回家了,明天继续写完. 大家还需要什么操作,留言说一下,没有的我明天继续加. 好久没有玩DevExpress了,今天下载了一个玩玩,发现竟然更新到14.2.5了..我去 ...
- jsp富文本图片和数据上传
好记性不如烂笔头,记录一下. 2016的最后一天,以一篇博客结尾迎接新的一年. 此处用的富文本编辑器是wangEditor,一款开源的轻量级的富文本编辑器,这里着重说一下里面的图片上传功能. 服务器端 ...
- UEditor百度富文本编辑器--让编辑器自适应宽度的解决方案
UEditor百度富文本编辑器的initialFrameWidth属性,默认值是1000. 不能够自适应屏幕宽度.如图1: 刚开始的时候,我是直接设置initialFrameWidth=null的.效 ...
- iOS - NSMutableAttributedString富文本的实现
NSMutableAttributedString继承于NSAttributedString(带属性的字符串)能够简单快速实现富文本的效果;不多说直接上效果图和代码,通俗易懂: (一)效果图: (二) ...
- 【代码笔记】iOS-获得富文本设置以后的文字高度
一,效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> @interface RootViewController ...
- PHP Ueditor 富文本编辑器
2016年12月11日 08:46:59 星期日 百度的简版富文本编辑器umeditor很久没更新了 全功能版本的配置项跟umeditor还是有区别的, 这里说下ueditor怎么对接到项目中去, 主 ...
- Java 实现HTML富文本导出至word完美解决方案
一. 问题的提出 最近用java开发一个科技项目信息管理系统,里面有一个根据项目申请书的模板填写项目申报信息的功能,有一个科技项目申请书word导出功能. 已有的实现方式:采用标准的jsp模板输出实现 ...
随机推荐
- 【Python】回文
首先判断一个字符串是否回文: def isPlalind(s): if len(s) == 1: return True else: return s[0] == s[-1] and isPlalin ...
- SQLite语句
搜索某属性: select exp from player where level = 2; 创建表: create table player (level integer primary key, ...
- C#操作xml文件进行增、删、改
进行操作的xml文件: products.xml <?xml version="1.0" encoding="utf-8"?><product ...
- CNN计算过程
- 原 iOS深入学习(Block全面分析)http://my.oschina.net/leejan97/blog/268536
原 iOS深入学习(Block全面分析) 发表于1年前(2014-05-24 16:45) 阅读(26949) | 评论(14) 39人收藏此文章, 我要收藏 赞21 12月12日北京OSC源创会 ...
- JAVA多态问题总结(课堂总结)
面向对象的三大特性:封装.继承.多态.从一定角度来看,封装和继承几乎都是为多态而准备的.这是我们最后一个概念,也是最重要的知识点.多态的定义:指允许不同类的对象对同一消息做出响应.即同一消息可以根据发 ...
- 转: Executor类
Executor框架是指java 5中引入的一系列并发库中与executor相关的一些功能类,其中包括线程池,Executor,Executors,ExecutorService,Completion ...
- Valid Number--LeetCode
class Solution { public: bool isNumber(string s) { if(s == " ") return false; ; ; while(s[ ...
- Jmeter:相应断言介绍
Jmeter进行性能测试时,作为对上一个请求返回信息的校验,基本上断言是不可少的,今天主要介绍一下Jmeter的相应断言校验. 相应断言:即对服务器相应信息的校验判断,发送http请求后,对服务器返回 ...
- iOS开发关于xcode中souceControl的苹果文档翻译(节选)
Subversion 1.7 provides many benefits: svn1.7版本有以下好处: Improved performance. Increased speed for many ...