简体   繁体   English

加载属性文件以获取键值对

[英]Load the properties file to get the key value pair

PasswordBlurb7=\u4E0D\u53EF\u4F7F\u7528\u91CD\u8907\u5B57\u5143\uFF08\u4F8B\u5982 aaa64135\u3001111bcxjk\uFF09

One of my properties file contains the above key=value pair. 我的一个属性文件包含上面的key = value对。 So when I try to load this key. 所以当我尝试加载这个键时。 I do not get the value. 我没有得到价值。 I get ???????? 我明白了???????? in the value 在价值中

  Properties prop = new Properties();
  InputStream in = application.getResourceAsStream("WEB-INF/classes/content/"+line);
String value;
prop.load(in); 
for(Object str: prop.keySet()) {
            value = prop.getProperty((String) str);
            hashMap.put((String)str, value);

}

So in the value I get like this-- 所以我觉得这样的价值 -

??????????? aaa64135?111bcxjk? 

I am outputting like this-- 我输出像这样 -

<html>
<head>
</head>
<body>
<table border='2'>
<tr>
<th>Key</th>
<th>Values</th>
</tr>
<%
                        for (Entry<String, String> entry : hashMap.entrySet()) {
                                        String key = entry.getKey();
                                        String value = entry.getValue();
%>
<tr><td>
<% out.println(key); %>
</td>
<td>
<% out.println(value);  %>
</td></tr>
<%                                                      }
                        //out.println(hashMap);
                        } catch (FileNotFoundException e1) {
                                    e1.printStackTrace();
                        }
                        catch (IOException e) {
                                    e.printStackTrace();
                        } finally {

                        }

%>
</table>
</body>
</html>

Anything wrong with my code.. 我的代码有什么问题..

The property is a string containing unicode-escaped characters. 该属性是一个包含unicode转义字符的字符串。 The reason you see ?????... is most likely that the output device you are using does not handle unicode, or that it is using a font that does not contain these asian symbols: 您看到?????...的原因很可能是您使用的输出设备不处理unicode,或者它使用的字体不包含这些亚洲符号:

\u4E0D\u53EF\u4F7F\u7528\u91CD\u8907\u5B57\u5143\uFF08\u4F8B\u5982 aaa64135\u3001111bcxjk\uFF09 

不可使用重複🈑兇元(例如aaa64135、111bcxjk)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM