java - 使用 fmt 标签在 jsp 中进行国际化

标签 java jsp

    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
    <html>
    <head>
    <title>JSTL fmt:message Tag</title>
    </head>
    <body>

    <fmt:setLocale value="en"/>
    <fmt:setBundle basename="com.tutorialspoint.Example" var="lang"/>

    <fmt:message key="count.one" bundle="${lang}"/><br/>
    <fmt:message key="count.two" bundle="${lang}"/><br/>
    <fmt:message key="count.three" bundle="${lang}"/><br/>

    </body>
    </html>

我在这里使用 jSTL 的 fmt 标签来显示此输出。 ???数一??? ???数二??? ???数三???

最佳答案

您提到的 bundle 中是否有关联的属性文件

<fmt:setBundle basename="com.tutorialspoint.Example" var="lang"/>

如果没有,您需要在 com >tutorialspoint 中有一个名为 tutorialspoint.properties 的属性文件,其中应包含,

count.one=one  
count.two=two  
count.three=three

并且,对于不同的setLocale喜欢 fr您应该使用tutorialspoint_fr.properties等等。

关于java - 使用 fmt 标签在 jsp 中进行国际化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28082404/

相关文章:

java - doFilter() 中 servletRequest.setAttribute 线程安全吗?

web-services - 如何创建简单的网页来显示 Jersey Web 服务结果?

mysql - 如何将excel数据上传到mysql表中

javascript - 如何将 Javascript 变量传递给 Struts param 标记?

java - 我如何比较 Java 中的原始时间?

java - (a)Smack 在登录时返回 "service-unavailable (503)"错误()

java - 无法从 Google Plus 访问用户的个人资料

java - 仅在保存实体时制作 transient 列

java - 在 JSTL 中将小数解析为整数

java - 在java中使用XOauth2通过IMAP连接到microsoft Outlook.com