我正在与 JSF 合作。我使用了 RichFaces 的“RichEditor”。我将此编辑器中的内容存储到 bean 中并显示为 JSF 表单。但它在 JSF 表单上显示 HTML 标记。为此,我使用了 JSoup HTML Parser。但它完全将富编辑器的书面内容转换为简单的文本,删除所有格式,如粗体、使用的按钮、换行符等。我需要以 jSF 形式作为编辑器显示。
请帮忙...
富编辑器的代码
<f:param name="theme_advanced_buttons1" value="
newdocument,separator,copy,cut,paste,pasteword,undo,redo,separator,bold,italic,underline,
strikethrough,forecolor,backcolor,separator,
justifyleft,justifycenter,justifyright,justifyfull,outdent,indent " />
<f:param name="theme_advanced_buttons2" value= "bullist,numlist,separator,
insertdate,inserttime,separator,image,emotions,styleprops,fontselect,fontsizeselect,formatselect,search,replace"/>
<f:param name="theme_advanced_toolbar_location" value="top"/>
<f:param name="theme_advanced_toolbar_align" value="left"/>
<f:param name="theme_advanced_font_sizes" value="10px,12px,14px,16px,18px,20px,24px,32px,36px,42px,48px,60px,72px"/>
<f:param name="theme_advanced_fonts" value="Andale Mono=andale mono,times;
Arial=arial,helvetica,sans-serif;
Arial Black=arial black,avant garde;
Book Antiqua=book antiqua,palatino;
Calibri=calibri;
Comic Sans MS=comic sans ms,sans-serif;
Courier New=courier new,courier;
Georgia=georgia,palatino;
Helvetica=helvetica;
Impact=impact,chicago;
Symbol=symbol;
Tahoma=tahoma,arial,helvetica,sans-serif;
Terminal=terminal,monaco;
Times New Roman=times new roman,times;
Trebuchet MS=trebuchet ms,geneva;
Verdana=verdana,geneva;
Webdings=webdings;
Wingdings=wingdings,zapf dingbats"/>
</rich:editor>
来自Java....
公共字符串保存通知(){
System.out.println(html2text(editor));
return "";
}
public String html2text(String editor)
{
String edit;
edit=Jsoup.parse(editor).text();
setEditor(edit);
return edit;
}