我正在使用 thymeleaf 和 spring 3 mvc。当我尝试执行 Ajax POST 请求时,我不明白如何在我的 html 页面上显示来自控制器的响应消息:
这是一个代码片段:
$.ajax({
    type: "POST",
    url: "/settings",
    data: "request=" + request,
    success: function (response) {
        $('#msg').replaceWith('<div id="msg" th:text="response"></div>');
    },
});
“响应”是来自控制器的 i18n 消息。现在,我想在使用 thymeleaf (th:text="response") 时显示此消息。当然,这段代码不起作用,因为它认为响应变量是一个纯字符串。
问题是如何使用 thymeleaf 显示 i18n 响应消息。或者也许还有其他方法可以通过 js 在 html 页面(不使用 jsp)上显示 i18n 消息?