我正在使用JSF。我已經使用了RichFaces的「RichEditor」。我將來自此編輯器的內容存儲到一個bean中並顯示爲一個JSF表單。但它顯示了JSF表單上的HTML標籤。爲此,我使用JSoup HTML Parser。但它將富文本編輯器的書面內容完全轉換爲簡單文本,刪除所有格式,如粗體,使用的按鈕,換行符等。我需要以編輯器的形式顯示在jSF表單中。將html轉換爲文本
請幫助...
CODE爲富文本編輯器
<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 ....
公共字符串saveNotice(){
System.out.println(html2text(editor));
return "";
}
public String html2text(String editor)
{
String edit;
edit=Jsoup.parse(editor).text();
setEditor(edit);
return edit;
}
你能給我們一個鏈接到演示或從您的瀏覽器頁面源代碼?這對希望得到幫助的人會更有幫助。 – reporter 2011-04-01 09:50:19