javascript - 如何在 Spring MVC 中的 javascript 中显示属性文件中的值

标签 javascript java html spring-mvc

我正在设置硬编码消息,例如:“您确定要删除该消息吗?” ,在 message.properties 文件中。

想要将此消息从 message.properties 提取到 JavaScript 中。 请建议我实现这一目标的方法。

例如:

BootstrapDialog.show({
            message: 'Are you sure you want to '+activeStatus+' this message ?',
            title: 'Alert'
});


function handleAjaxError(xhr, textStatus, error) {

    if (textStatus == 'timeout') {
        alert('The server took too long to send the data.');
    } else if (textStatus == "parsererror") {
        alert("Ajax error occured.");
    }
}

最佳答案

看看 Spring 主题标签:

Retrieves the theme message with the given code, or text if code isn't resolvable. The HTML escaping flag participates in a page-wide or application-wide setting (i.e. by HtmlEscapeTag or a "defaultHtmlEscape" context-param in web.xml).

<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<spring:theme code="code.of.your.message" text="Alternative text"/>

关于javascript - 如何在 Spring MVC 中的 javascript 中显示属性文件中的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36309647/

相关文章:

java - 如何告诉 java 编译器允许 public 作为包名?

java - Rome XmlReader 不读取 https 提要

javascript - 如何解决 Google Chrome 中的 Roboto 字体加载问题?

html - Flexbox 定义列的宽度并左对齐

javascript - jquery如何取消选中单选按钮

javascript - jQuery 1.x 和 IE8 的 addEventListener 错误

javascript - 如何开始使用 Node.js

java - 使用 zxing 从 camera2 拍摄的照片中解码数据矩阵

jquery - 如何创建一个接受 24 小时制时间的 HTML 输入字段?

javascript - Webpack 中特定于页面的 JavaScript 以及第三方脚本和应用程序范围的脚本