<%@ 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/