我现在需要做一个中英文的网站,默认应该是英文,没这方面的经验,在网上看了一下关于如何国际化的例子,但没有做成功,特来请教一下,一下介绍一下我目前实现国际化的情况。
1、首先在src下有3个文件,分别是native2ascii.xml、info.properties和info_en_US.properties,允许native2ascii.xml会生成info_zh_CN.properties,native2ascii.xml中的内容:<?xml version="1.0"?><project name="lewis" basedir="." default="native">
<target name="native">
<native2ascii encoding="UTF-8" src="."
dest="." includes="info.properties" ext="_zh_CN.properties" />
</target>
</project>info.properties中的内容:
userinfo.id=乐维用户ID
userinfo.password=登录密码info_en_US.properties中的内容:
userinfo.id=leiws ID
userinfo.password=password编码后info_zh_CN.properties中的内容:
userinfo.id=\u4e50\u7ef4\u7528\u6237ID
userinfo.password=\u767b\u5f55\u5bc6\u7801然后index.jsp页面,这个页面是在网站上面选择中英文语言用的,暂时简化了网站代码:<table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td align="center" id="loginhref">
        <a href="javaScript:setMainIframe('user/Login')" class="link_1">登陆</a> |  
        <a href="javaScript:setMainIframe('user/Register')" class="link_1">注册</a>
        </td>
        <td>&nbsp;</td>
        <td align="center">
        <a href="#" class="link_1">中文</a> |  
        <a href="#" class="link_1">English</a>
        </td>
        </tr>
</table>其次是登陆页面:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" contentType="text/html;charset=GBK"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<c:if test="${!empty parem.language}">
<fmt:setLocale value="${param.language}" scope="session"/>
</c:if>
<%@ taglib uri="/WEB-INF/tld/spring-form.tld" prefix="form"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>lewis</title>
<link href="<%=request.getContextPath()%>/common/css/style.css" rel="stylesheet" type="text/css" /></head><fmt:bundle basename="messages">
<body>
<table width="85%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left"><fmt:message key="userinfo.id"/></td>
<td align="left"><fmt:message key="userinfo.password"/></td>
</tr>
</table>
</body>
</fmt:bundle>
</html>
web.xml文件我没有加配置,然后访问到登陆页面的时候,就显示???userinfo.id???和???userinfo.password???我是不是少配置一些东西了,还是需要做一些其他的工作?