Java 如何在Jsp中从Blob中删除Html标记

Java 如何在Jsp中从Blob中删除Html标记,java,html,jsp,struts2,blob,Java,Html,Jsp,Struts2,Blob,我有DocumentVariable(strutsbean变量和blob数据),它包含数据和Html标记。如何删除html标记并仅显示文本 <s:label name="documentDAO.documentAllContent" /> <p>/*<br /> &nbsp;* This is a JavaScript Scratchpad.<br /> &nbsp;*<br /> &nbsp;* Enter

我有
DocumentVariable
(strutsbean变量和blob数据),它包含数据和Html标记。如何删除html标记并仅显示文本

<s:label name="documentDAO.documentAllContent" />

<p>/*<br /> &nbsp;* This is a JavaScript Scratchpad.<br /> &nbsp;*<br /> &nbsp;* Enter some JavaScript, then Right Click or choose from the Execute Menu:<br /> &nbsp;* 1. Run to evaluate the selected text (Ctrl+R),<br /> &nbsp;* 2. Inspect to bring up an Object Inspector on the result (Ctrl+I), or,<br /> &nbsp;* 3. Display to insert the result in a comment after the selection. (Ctrl+L)<br /> &nbsp;*/</p> <p>&nbsp;</p> 

/*
*这是一个JavaScript草稿行。
*
*输入一些JavaScript,然后右键单击或从执行菜单中选择:
*1。运行以计算所选文本(Ctrl+R),
*2。检查以在结果上显示对象检查器(Ctrl+I),或,
*3。Display可在选择后的注释中插入结果。(Ctrl+L)
*/


这个问题还不清楚,但可能值得一个涵盖所有案例的解释

您可以使用CKEditor创建一个HTML,然后将其保存到
BLOB
字段中(该字段应用于二进制数据,这里需要的是
CLOB
,但这是另一个故事)

然后检索内容,此时可能会得到三种不同的预期结果:

  • HTML(例如,
    foo
    呈现为
    foo
    ):

    
    
  • 纯文本(例如,
    foo
    呈现为
    foo

    
    
  • 无HTML标记的纯文本(例如,
    foo
    呈现为
    foo
    ):为此,您需要在action类中使用HTML解析器(例如,as)

    private byte[]yourVar;
    公共字符串getYourVar(){
    返回Jsoup.parse(新字符串(yourVar,“UTF-8”)).text();
    }
    
    
    

  • 为什么要使用
    标记?使用
    -默认情况下,它会转义html。我使用的是来自CKEditor的数据,即使我使用的是带有标记的数据 sfhsdfhsdf

    sfdhsfdhsfsdfh

    hgdf

    你想逃离他们吗?如果没有,则将
    escapeHtml
    属性设置为false。我想删除html标记并在JSP上显示纯文本而不设置格式?那你为什么要用ckeditor呢?