Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Internationalization 使用jstl标记使应用程序国际化_Internationalization_Jstl - Fatal编程技术网

Internationalization 使用jstl标记使应用程序国际化

Internationalization 使用jstl标记使应用程序国际化,internationalization,jstl,Internationalization,Jstl,我正在尝试使用JSP中的JSTL标记对我的应用程序进行国际化。我的问题是,属性文件的内容在UI中不可见 JSP代码 <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/l

我正在尝试使用JSP中的JSTL标记对我的应用程序进行国际化。我的问题是,属性文件的内容在UI中不可见

JSP代码

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"  prefix="fmt"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
This Example demonstrates the basic JSTL formating tags:
<br/><br/>
Locale from client:

<b><c:out value="${pageContext.request.locale}"/></b><br/>

<fmt:setBundle basename="ApplicationResources" var="mybundle"/>
<fmt:message key="welcome.message" bundle="${mybundle}">
   <fmt:param value="${param.uname}"></fmt:param>
</fmt:message>
<b>Now testing &lt;fmt:setLocale&gt;tag:</b><br>
Creating a ResourceBundle with client locale and setting it to <i>mybundle1</i>
variable.<br>
<fmt:setBundle basename="ApplicationResources" var="mybundle1"/>
Setting the locale to<i>it</i>(italian).<br/>
<fmt:setLocale value="it"/>
Creating a ResourceBundle with <i>it</i>(italian) locale and setting it to <i>mybundle2</i> variable.<br><br>
<fmt:setBundle basename="ApplicationResources" var="mybundle2"/>
<b>Message using <i>mybundle1</i>:</b><br>
<pre>
 <fmt:message bundle="${mybundle1}" key="welcome.message">

 </fmt:message>
</pre>
<br>
<b>Message using <i>mybundle2</i>:</b><br>
<pre>
<fmt:message bundle="${mybundle2}" key="welcome.message">

</fmt:message>
</pre>
</body>
</html>

在此处插入标题
此示例演示了基本的JSTL格式化标记:


来自客户端的区域设置:
现在正在测试fmt:setLocaletag:
使用客户端语言环境创建ResourceBundle并将其设置为MyBundle 1 变量。
将区域设置设置为It(意大利语)。
使用它(意大利语)语言环境创建ResourceBundle并将其设置为mybundle2变量。

使用mybundle1的消息:

使用mybundle2的消息:
渲染输出为:

<fmt:setBundle basename="ApplicationResources" var="mybundle1"/>
<fmt:setBundle basename="ApplicationResources" var="mybundle2"/>
此示例演示了基本的JSTL格式化标记:
来自客户的区域设置:en_US
欢迎。留言???现在测试标签:
使用客户端语言环境创建ResourceBundle并将其设置为mybundle1变量。
将区域设置设置为(意大利语)。
使用它(意大利语)语言环境创建ResourceBundle并将其设置为mybundle2变量。
使用mybundle1的消息:
欢迎。留言???
使用mybundle2的消息:
欢迎。留言???

我相信这是我们需要开始的。创建两个名为:

  • ApplicationResources.properties
  • 应用程序资源\u it.properties
  • 两者都应包含(至少)类似条目:

    删除这些不必要的声明:

    
    

    移动到页面顶部。无论哪种方式,它都会设置整个页面的区域设置,我认为没有混合语言的方法(感谢上帝)。

    您愿意花时间阅读吗?您的问题有严重的格式问题,您的要求不明显。你刚才说你有问题。可能是重复的
    welcome.message=Hello,{0}
    
    <fmt:setBundle basename="ApplicationResources" var="mybundle1"/>
    <fmt:setBundle basename="ApplicationResources" var="mybundle2"/>