我正在使用一个 .properties 文件,其中包含我的电子邮件服务器名称以及发件人和收件人地址:
printServer=xxx.Xxx.xxx
sender=xxxx-xxxx@xxxx.xxxx.xxx
receiver=xxxx-xxxx@xxxx.xxxx.xxx
当我尝试检索发件人值时,我收到此错误:
javax.mail.internet.AddressException: Illegal whitespace in address in string ``!!key =sender!!''
fr.srd.remap.runtime.PclReportGenerator.sendReporttest(PclReportGenerator.java:120)
... 40 more
这里我使用的方法:
public static String getString(String key, String bundleName) {
try {
ResourceBundle resourceBundle;
resourceBundle = ResourceBundle.getBundle(bundleName);
System.out.println(resourceBundle.getString(key));
return resourceBundle.getString(key);
} catch (MissingResourceException e) {
return "!!key =" + key + "!!";
}
}
这里的原则错误:
java.util.MissingResourceException: Can't find bundle for base name server, locale en_US
at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1499)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1322)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:724)
我将属性文件命名为:server.properties,所以名称有什么问题,我什至用这个名称 server_en.properties 对其进行了测试,但问题仍然存在。