tinymce整合struts2使用
在提交之前记得 instance.post();
这个应付老师检查还是可以的,但是很详细的怎么具体使用,还是要去看官方文档。
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>write</title>
<link rel="stylesheet" href="../css/style_tinyeditor.css" />
<script type="text/javascript" src="../js/tinyeditor.js"></script>
</head>
<script type="text/javascript">
var instance ;
window.onload = function() {
instance = new TINY.editor.edit('editor', {
id : 'input',
width : 584,
height : 175,
cssclass : 'te',
controlclass : 'tecontrol',
rowclass : 'teheader',
dividerclass : 'tedivider',
controls : [ 'bold', 'italic', 'underline', 'strikethrough', '|',
'subscript', 'superscript', '|', 'orderedlist',
'unorderedlist', '|', 'outdent', 'indent', '|',
'leftalign', 'centeralign', 'rightalign', 'blockjustify',
'|', 'unformat', '|', 'undo', 'redo', 'n', 'font', 'size',
'style', '|', 'image', 'hr', 'link', 'unlink', '|', 'cut',
'copy', 'paste', 'print' ],
footer : true,
fonts : [ 'Verdana', 'Arial', 'Georgia', 'Trebuchet MS' ],
xhtml : true,
cssfile : 'style.css',
bodyid : 'editor',
footerclass : 'tefooter',
toggle : {
text : 'source',
activetext : 'wysiwyg',
cssclass : 'toggle'
},
resize : {
cssclass : 'resize'
}
}); }; function refresh() {
instance.post();
var title = document.getElementById("title").value;
if (title == '') {
alert("标题不能为空!")
document.getElementById("title").focus();
return false ;
}
var input = document.getElementById("input").value;
if (input == '') {
alert("内容不能为空!");
document.getElementById("input").focus();
return false ;
}
return true ;
} </script>
<body>
<form action="${pageContext.request.contextPath}/post_write.action" method="post" onsubmit="return refresh()">
标题: <input type="text" name="title"
style="width:400px;height: 20px; align:center;" id="title">
<textarea id="input" style="width:400px; height:200px" name="content"></textarea>
<input type="submit" value="确定">
</form> </body> </html>
显示的效果:

textarea中的数据保存在数据库中的格式为:我用的数据库为mysql字段是用的longtext;
最后显示在数据库中的内容为:

将数据库中的数据用ognl表达式显示到页面上 ,刚开始我试过用js调用innerHTML将内容和html代码注入进去,但是会出现转义的问题,不知道是不是我写的有问题,但是下面这种写法是可以的。
<s:property value="post.content" escape="false" />//重要的是escape="false"这个属性,不然会将标签同时显示出来

tinymce整合struts2使用的更多相关文章
- spring整合struts2
1. Spring 如何在 WEB 应用中使用 ? 1). 需要额外加入的 jar 包: spring-web-4.0.0.RELEASE.jarspring-webmvc-4.0.0.RELEASE ...
- Spring 整合 Struts2
1. Spring 如何在 WEB 应用中使用 ? 1). 需要额外加入的 jar 包: spring-web-4.0.0.RELEASE.jar spring-webmvc-4.0.0.RELEAS ...
- Struts2的使用以及Spring整合Struts2
一.如何单独使用Struts2 (1)引入struts2的jar包 commons-fileupload-1.2.1.jar freemarker-2.3.15.jar ognl-2.7.3.jar ...
- Spring学习6-Spring整合Struts2
一.Spring为什么要整合Struts2 Struts2与Spring进行整合的根本目的就是要让 Spring为Struts2的Action注入所需的资源对象,它们整合的原理则是只要导入了s ...
- 基于注解整合struts2与spring的时候如果不引入struts2-spring-plugin包自动装配无效
基于注解整合struts2与spring的时候如果不引入struts2-spring-plugin包,自动装配将无效,需要spring注入的对象使用时将抛出空指针异常(NullPointerExcep ...
- Spring(四):Spring整合Hibernate,之后整合Struts2
背景: 上一篇文章<Spring(三):Spring整合Hibernate>已经介绍使用spring-framework-4.3.8.RELEASE与hibernate-release-5 ...
- Maven项目整合Struts2框架
-------------------------siwuxie095 Maven 项目整合 Struts2 框架 1. ...
- 整合Struts2框架和Spring框架
-----------------------siwuxie095 整合 Struts2 框架和 Spring 框架 1 ...
- Spring整合Struts2框架的第二种方式(Action由Spring框架来创建)(推荐大家来使用的)
1. spring整合struts的基本操作见我的博文:https://www.cnblogs.com/wyhluckdog/p/10140588.html,这里面将spring与struts2框架整 ...
随机推荐
- LeetCode 135 Candy(贪心算法)
135. Candy There are N children standing in a line. Each child is assigned a rating value. You are g ...
- SpringBoot读取配置文件
项目结构 pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http:// ...
- c# mybatis net +mysql
1找到 mybatis.net最好有个例子 http://www.codeproject.com/Articles/894127/WebControls/#_comments 在这里... 这是一 ...
- 【ORM】--FluentNHibernate之基本映射详解
最近在做项目的时候用到了NHibernate,使用它并不困难,但是很麻烦.如果我的数据库有几百张表如果想要一个个的映射岂不是很麻烦,所以这种情况下使用NHibernate就会很笨重,虽然 ...
- 老生长谈,温故知新:css实现右侧固定宽度,左侧宽度自适应
反过来也可以:左侧宽度固定,右侧自适应.不管是左是右,反正就是一边宽度固定,一边宽度自适应. 这种布局比较常见,博客园很多默认主题就是这种.一般情况下,这种布局中宽度固定的区域是侧边栏,而自适应的区域 ...
- linux下wps,系统缺失字体:wingdings、wingdings 2、wingdings3
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAArcAAACdCAIAAAAhV8dZAAAgAElEQVR4nOzdd1wT9/8H8OvXfjvtt8
- Android Activity 四种启动模式
task和back stack(任务和回退栈) 任务启动,task被加入到回退栈的栈顶,返回的时候回退栈的栈顶任务会被弹出,并被销毁,栈中的前一任务恢复运行,当activity销毁是,系统不会保留ac ...
- 通过SQL Server 2008数据库复制实现数据库同步备份
SQL Server 2008数据库复制是通过发布/订阅的机制进行多台服务器之间的数据同步,我们把它用于数据库的同步备份.这里的同步备份指的是备份服务器与主服务器进行 实时数据同步,正常情况下只使用主 ...
- EM算法(2):GMM训练算法
目录 EM算法(1):K-means 算法 EM算法(2):GMM训练算法 EM算法(3):EM算法运用 EM算法(4):EM算法证明 EM算法(2):GMM训练算法 1. 简介 GMM模型全称为Ga ...
- Linux 之集群 LVS
查看系统是否支持IPVS功能 [root@nginx ~]# grep -i 'ipvs' /boot/config-2.6.18-308.el5 # IPVS transport protocol ...