2011-05-06 2 views
0

JSP로 JSTL 태그를 사용하여 내 애플리케이션을 국제화하려고합니다. 내 문제는, 속성 파일의 내용이 UI에 표시되지 않는다는 것입니다.jstl 태그를 사용하여 애플리케이션 internationnalize 만들기

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> 

:

This Example demonstrates the basic JSTL formating tags: 

Locale from client: en_US 
???welcome.message??? Now testing <fmt:setLocale>tag: 
Creating a ResourceBundle with client locale and setting it to mybundle1 variable. 
Setting the locale toit(italian). 
Creating a ResourceBundle with it(italian) locale and setting it to mybundle2 variable. 

Message using mybundle1: 

???welcome.message??? 


Message using mybundle2: 

???welcome.message??? 
+0

[여기에 질문하는 방법]을 읽는 데 너무 친절하십니까? (http://msmvps.com/blogs/jon_skeet/archive/2010/08/29/writing-the-perfect-question. aspx)? 귀하의 질문에 심각한 서식 문제가 있으며 귀하가 무엇을 요구하고 있는지 분명하지 않습니다. 방금 문제가 있다고 하셨 잖아요. –

+0

가능한 [자바 웹 응용 프로그램을 국제화하는 방법] (http://stackoverflow.com/questions/4276061/how-to-internationalize-a-java-web-application) – BalusC

답변

1

나는 이것이 우리가 시작해야 할 것입니다 생각합니다. 두 이름이 지정된 파일 만들기 :

  1. ApplicationResources.properties을
  2. ApplicationResources_it.properties

모두가 (적어도) 유사한 항목이 포함되어 있어야합니다

welcome.message=Hello,{0} 

이러한 불필요한 선언을 제거

<fmt:setBundle basename="ApplicationResources" var="mybundle1"/> 
<fmt:setBundle basename="ApplicationResources" var="mybundle2"/> 

<fmt:setLocale value="it"/> 페이지로 이동하십시오. 어느 쪽이든 전체 페이지에 대한 로케일을 설정합니다. 언어를 혼합하는 방법이 없다고 생각합니다 (하나님 께 감사드립니다).

관련 문제