Jsp页面获取properties文件中的数据

第一步:在页面顶部添加import="java.util.*"

ResourceBundle res = ResourceBundle.getBundle("properties.resource");

这里写图片描述

第二步:
这里写图片描述

第三步:
这里写图片描述

备注:中文乱码解决

1.解决方法一:在使用keyValue时,进行编码转换
view plaincopy to clipboardprint?
String keyValue = new String(rb.getString(keyName).getBytes(“ISO-8859-1”), “GBK”);

String keyValue = new String(rb.getString(keyName).getBytes(“ISO-8859-1”), “UTF-8”);

2.解决方法二:将machine_zh_CN.properties转换成为unicode形式

native2ascii.exe machine_zh_CN.properties machine_zh_CN.txt

p1=/u51b0/u7bb1 p2=/u6d17/u8863/u673a p3=/u7535/u89c6/u673a

猜你喜欢

转载自blog.csdn.net/tangxingiloveyou/article/details/79423385
今日推荐