在jsp页面中使用tinymce
<%@ page language="java" pageEncoding="GBK"%>
<%@ page contentType="text/html; charset=GBK"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c"%>
<%@ taglib uri="/WEB-INF/jpager.tld" prefix="page"%>
<%@ taglib uri="/WEB-INF/cvicse-param.tld" prefix="param"%>
<%
response.setHeader("Pragma", "No-cache");//HTTP 1.1
response.setHeader("Cache-Control", "no-cache");//HTTP 1.0
response.setHeader("Expires", "0");//防止被proxy
%>
<html>
<head>
<title>NewsLetter添加修改</title>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<link type="text/css" rel="stylesheet" href="css/aaabbb.css">
<script type="text/javascript" src="${pageContext.request.contextPath }/js/jscripts/tiny_mce/tiny_mce.js">
</script>
<script type="text/javascript">
tinyMCE.init({
// General options
mode : "exact",
elements : "content",
theme : "advanced",
skin : "o2k7",
plugins : "advlink,pagebreak,style,table,emotions,insertdatetime,preview,searchreplace,print,paste,directionality,fullscreen,nonbreaking,inlinepopups",
// Theme options
theme_advanced_buttons1 : "newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,link,unlink,|,code,insertdate,inserttime,preview,|,forecolor,backcolor",
theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,|,sub,sup,|charmap,emotions,advhr,|,print,|,ltr,rtl,|,fullscreen,|,nonbreaking,pagebreak,image",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
// theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
// 图片等URL加全路径
relative_urls: false,
remove_script_host: false,
// Example content CSS (should be your site CSS)
content_css : "${pageContext.request.contextPath}/js/jscripts/tiny_mce/stylecss/content.css",//必须有,供样式选择用
// Drop lists for /image/template dialogs
template_external_list_url : "../js/jscripts/tiny_mce/lists/template_list.js",
// external_image_list_url : "../js/jscripts/tiny_mce/lists/image_list.js",
// Replace values for the template plugin
template_replace_values : {
username : "Some User",
staffid : "991234"
}
});
function Save(){
with(document.forms[0]){
if(title.value == "" || title.value==null){
alert("请输入邮件标题!");
return false;
}
// replace(/^\s*|[\x00-\x1f]|\s*$/g, '') 去掉textarea中不可见字符
if(content.value == "" || content.value==null){
alert("请输入邮件正文!");
return false;
}
if (id.value == "") {
operFlag.value = "add";
} else {
operFlag.value = "update";
}
// alert(operFlag.value);
submit();
}
}
function Back(){
with(document.forms[0]){
document.getElementById("title").value = "";
document.getElementById("content").value = "";
action="<%=request.getContextPath()%>/letter.do";
submit();
}
}
</script>
</head>
<%
String id = (String) request.getAttribute("id");
if (id == null || id.equals("")) {
id = "";
}
%>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<center>
<br>
<br>
<br>
<html:form styleId="letterForm" action="letterEdit.do?method=letteraddedit" method="post">
<html:hidden name="letterForm" property="operFlag" styleId="operFlag" />
<html:hidden name="letterForm" property="id" styleId="id" />
<div align="left"><html:errors /></div>
<table width="100%" border="0" cellpadding="1" cellspacing="0"
bordercolor="#126DC9" bgcolor="#f2f8ff"
style="border-collapse: collapse">
<thead>
<tr align="center">
<th colspan="4">
邮件<%
if ("".equals(id)) {
out.print("添加");
} else {
out.print("修改");
}
%>
</th>
</tr>
</thead>
<tr>
<td valign="middle"> <div align="right">邮件标题 :</div></td>
<td height="25">
<input id="title" type="text" name="title" value="${title }" style="width:60%;height: 100%;line-height: 23px"/>
</td>
</tr>
<tr height="330" valign="top">
<td valign="top"> <div align="right">邮件正文 :</div></td>
<td>
<textarea id="content" name="content" rows="30" cols="130" style="width: 100%">
<c:out value="${content}" escapeXml="false"></c:out>
</textarea>
</td>
</tr>
<tr bgcolor="f5f5f5">
<td colspan="2"> <div align="center">
<input type="button" value=" 保存 " οnclick="Save();">
<input type="button" value=" 返回 " οnclick="Back();">
</div></td>
</tr>
</table>
</html:form>
</center>
</body>
</html>