首先下载struts2使用的插件:struts2-jquery-richtext-plugin.jar (点击下载)
在使用的页面添加标签:
<%@ taglib prefix="sjr" uri="/struts-jquery-richtext-tags"%>
下面是编辑器的默认值:
<sjr:ckeditor
id="richtextEditor"
name="echo"
rows="10"
cols="80"
width="800"
value="Cras dictum. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia mauris vel est. Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos."
/>
下面是个简短的例子:
页面上的东西:
<%@ taglib prefix="sjr" uri="/struts-jquery-richtext-tags"%>
<sjr:ckeditor
label="Your Text"
href="%{remoteurl}"
id="richtextCustomeEditor"
name="echo"
rows="10"
cols="80"
loadingText="Loading content of textarea ..."
width="600"
toolbar="MyToolbar"
skin="v2"
editorLocal="fr"
customConfig="%{contextPath}/js/ckeditor.config.js"
注意红色的js文件
自己放代码如下:
CKEDITOR.editorConfig = function( config )
{
config.toolbar = 'MyToolbar';
config.toolbar_MyToolbar =
[
['NewPage','Preview'],
['Cut','Copy','Paste','PasteText','PasteFromWord','-','Scayt'],
['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],
'/',
['Styles','Format'],
['Bold','Italic','Strike'],
['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
['Link','Unlink','Anchor']
];
};
这样基本可以用了