【问题标题】:When I store data from servlet to mysql database characters like "<", ">" are stored as unicode format like u003c rather than the actual symbol当我将数据从 servlet 存储到 mysql 数据库时,像“<”、“>”这样的字符被存储为像 u003c 这样的 unicode 格式,而不是实际的符号
【发布时间】:2019-02-21 14:41:22
【问题描述】:

我正在尝试将数据存储在我的数据库测试中,例如“”存储为“u003c hi u004e”,我的数据库使用 utf8mb4 字符集。但我也尝试了 utf8、utf 32 等,但没有成功。

【问题讨论】:

标签: mysql database servlets unicode


【解决方案1】:

问题不在于 Mysql Db。问题出在 gson/json 库上。

使用这段代码来解决它。

   Gson gsonBuilder =new GsonBuilder().disableHtmlEscaping().create();

【讨论】:

    猜你喜欢
    • 2020-07-19
    • 2014-07-31
    • 2016-06-11
    • 1970-01-01
    • 2017-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-14
    • 2016-11-30
    相关资源
    最近更新 更多