我们的页面想要实现多语言国际化
我们先来一个简单的页面
<html>
<head>
<title>login</title>
</head>
<body>
<form action="" method="post">
用户名:<input type="text" name="username"><br/>
密 码:<input type="text" name="password"><br/>
<input type="submit" value="登录"><br/>
</form>
</body>
</html>
我们现在想要实现国际化
那么就要把所有字符串都写成变量
这样的话我们就可以进行替换
我们需要写两个配置文件,一个文件中存放中文信息
一个存放英文信息
我们使用一个类识别加载哪一个文件的信息
zh_CN
en_US
我们创建两个properties文件
1.res_en_US.properties
2.res_zh_CN.properties
<%
Locale china = Locale.CHINA;
ResourceBundle bundle = ResourceBundle.getBundle("res", china);
String username = bundle.getString("username");
String password = bundle.getString("password");
String login = bundle.getString("login");
%>