本文介绍了如何从ckeditor提取纯文本在JAVA中生成html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用ckeditor编写电子邮件,我使用它生成的html发送html电子邮件广告我还需要文本版本也,所以在电子邮件中具有html和纯文本版本将避免垃圾邮件。 / p>
在java中从ckeditor html代码中获取文本的方法是什么。
解决方案
这是相当简单的JavaScript调用:
CKEDITOR.instances.yourEditorInstance.getData()
返回:
; h1> Apollo 11< / h1>
< p>< b>阿波罗11< / b>是登陆第一批人类的航天器,美国人< a href =http://en.wikipedia.org/wiki/Neil_Armstrongtitle =Neil Armstrong> Neil Armstrong< / a>和< a href =http://en.wikipedia.org/wiki/Buzz_Aldrintitle =Buzz Aldrin> Buzz Aldrin< / a> ;,于1969年7月20日20:18 。阿姆斯特朗成为第一个踏上月球表面6小时后在7月21日02:56 UTC。< / p>但是: code> CKEDITOR.instances.yourEditorInstance.editable()。getText()
/ p>
阿波罗11
阿波罗11号是第一个人类,美国人Neil Armstrong和Buzz Aldrin 1969年7月20日,世界标准时间20:18。阿姆斯特朗成为第一个步入到月球表面6小时后在7月21日02:56 UTC。
I am using ckeditor to compose the emails, I am using the html generated by it to send the html emails ad i also need the text version also, So having both html and plain text version in emails will avoid the spam.
What is the way to get the text from ckeditor html code in java.
解决方案
This is quite simple JavaScript call:
CKEDITOR.instances.yourEditorInstance.getData()
Returns:
<h1>Apollo 11</h1>
<p><b>Apollo 11</b> was the spaceflight that landed the first humans, Americans <a href="http://en.wikipedia.org/wiki/Neil_Armstrong" title="Neil Armstrong">Neil Armstrong</a> and <a href="http://en.wikipedia.org/wiki/Buzz_Aldrin" title="Buzz Aldrin">Buzz Aldrin</a>, on the Moon on July 20, 1969, at 20:18 UTC. Armstrong became the first to step onto the lunar surface 6 hours later on July 21 at 02:56 UTC.</p>
However:
CKEDITOR.instances.yourEditorInstance.editable().getText()
Returns:
Apollo 11
Apollo 11 was the spaceflight that landed the first humans, Americans Neil Armstrong and Buzz Aldrin, on the Moon on July 20, 1969, at 20:18 UTC. Armstrong became the first to step onto the lunar surface 6 hours later on July 21 at 02:56 UTC.
这篇关于如何从ckeditor提取纯文本在JAVA中生成html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!