Java StringEcapeUtils不适用于•
我有一个HTML字符串存储在数据库中,如下所示Java StringEcapeUtils不适用于•,java,
elasticsearch,logstash,Java,
elasticsearch,Logstash,我有一个HTML字符串存储在数据库中,如下所示 1•DAY Brand<sup>®</sup>Brand<sup>®</sup>details—\r\n<BR>\r\n<BR>\r\n<p>This Brand® is the best for you needs. Plus our Water® Technology is more com
1•DAY Brand<sup>®</sup>Brand<sup>®</sup>details—\r\n<BR>\r\n<BR>\r\n<p>This Brand® is the best for you needs. Plus our Water® Technology is more comfort for you. Brand® offers the best in class mileage./p>\r\n<UL> \r\n <LI>Brand® is the #1 selling brand globally.\r\n <LI>Experience all-day comfort with Water® Technology.\r\n <LI>One of the highest levels of Mileage available in fuel.\r\n</UL>
我将再次使用escapeHtml4()来解决这个问题。但这是行不通的。我在这里面临的问题是当我做这个
时,这就是代码>不会在浏览器中的html中显示。此外,缺少对齐。
PFB日志存储脚本:
input{ file
{
path => ["C:/input.json"]
start_position => "beginning"
sincedb_path => "/dev/null"
}}filter{
mutate
{
replace => [ "message", "%{message}" ]
gsub => [ 'message','\n','']
}
json { source => message }
mutate{
remove_field => ["message"]
}}output {
elasticsearch {
hosts => ["localhost:9200"]
index => "index"
document_type => "type"
document_id => "%{id}"
}
stdout { codec => rubydebug }
}
有人能帮忙吗。在构建JSON时,您是否尝试过在字符串上调用replaceAll(“”,“®;”)
,但我不确定会有多少这样的字符。这些字符串是如何首先存储在您的数据库中的?@Val我们有一个内容管理系统,它将这些字符串存储在数据库中。这个字符串是由我们无法控制的业务用户构造的。好吧,因为这些字符串同时包含转义实体和未转义实体,我认为您先转义然后再转义的方法是正确的。您是否尝试过org.apache.commons.lang3.StringEscapeUtils.escapeHtml4
?
input{ file
{
path => ["C:/input.json"]
start_position => "beginning"
sincedb_path => "/dev/null"
}}filter{
mutate
{
replace => [ "message", "%{message}" ]
gsub => [ 'message','\n','']
}
json { source => message }
mutate{
remove_field => ["message"]
}}output {
elasticsearch {
hosts => ["localhost:9200"]
index => "index"
document_type => "type"
document_id => "%{id}"
}
stdout { codec => rubydebug }
}