简体   繁体   English

Spring Boot MVC / Thymeleaf和“替换字符”

[英]Spring Boot MVC/Thymeleaf and the 'replacement character'

we are developing an application which should display contents from a file. 我们正在开发应显示文件内容的应用程序。 This file could contain any characters from 0x00 to 0xFF . 该文件可以包含从0x000xFF任何字符。 These values should be displayed too (we are using a fallback font for this purpose). 这些值也应显示(为此,我们使用后备字体)。

But somehow these "special characters" (like 0x00 ) aren't displayed correctly. 但是,这些“特殊字符”(例如0x00 )以某种方式无法正确显示。 Something mapps these characters to the HTML replacement character (U+FFFD). 某些东西会将这些字符映射为HTML替换字符(U + FFFD)。

So now we need a solution how we can deliver the "correct" value (which would be replaced with the fallback font) to the HTML page/front end. 因此,现在我们需要一个解决方案,如何将“正确的”值(将由后备字体替换)传递到HTML页面/前端。

My first thought was to deliver the hex values (not the strings) and convert these values on the front end by javascript. 我的第一个想法是提供十六进制值(而不是字符串),并通过javascript在前端转换这些值。

Or are there smarter solutions? 还是有更智能的解决方案? Maybe an configuration in Spring MVC/Thymeleaf? 也许是Spring MVC / Thymeleaf中的配置?

试试这个th:utext="#{unescaped text}">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM