第一步、在src文件夹中加入struts.properties文件,内容如下:
struts.custom.i18n.resources=example //包名或其他
第二步、在src文件夹中加入example.properties文件,内容如下:
HelloWorld= /u4F60/u597D/uFF0C/u6B22/u8FCE/u8BBF/u95EE {0} //你好,欢迎访问
{0}表示第一个参数,{1},{2}表示第二、三个参数,以此类推。
现在MyEclipse7自带的properties工具已经无需再使用java的工具native2ascii进行汉字转换,如下图:
jsp文件如下:
<%@ page contentType="text/html; charset=GBK"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>
<s:text name="HelloWorld.message">
<s:param>我是谁</s:param>
</s:text>
</title>
</head>
<body>
<h2><s:property value="message"/></h2>
</body>
</html>