Вот мой код для замены тегов HTML:
def str
String.metaClass.removeHtml {
def removeThisHtml = [
[htmlCode: "`", value: "`"],
[htmlCode: "@", value: "@"],
[htmlCode: "&", value: "&"],
[htmlCode: "\", value: "\\"],
[htmlCode: """, value: '"'],
[htmlCode: "'", value: "'"],
[htmlCode: "<", value: "<"],
[htmlCode: ">", value: ">"]
]
removeThisHtml.each { element ->
str = delegate.replace(element.htmlCode, element.value)
}
return str
}
А вот код формы моего контроллера:
def getProjectLists() {
def currentUser = springSecurityService.currentUser
def kups = ([['name':'<b>Sample 1</b>'.removeHtml()],['name':'<b>Sample 2</b>']])
render kups as JSON
}
Мой ожидаемый результат:
Образец1 Образец2
Но вывод:
Образец1 Образец2