[英]How to read key from value of resource bundle/properties file
I have messages.properties bundle file which contains labels in key, value pair like我有messages.properties捆绑文件,其中包含键、值对中的标签,例如
meta.enum.ShipmentStatus.Loaded=Loaded
But I want read key from value ie from user/client view I get "Loaded" value and I want read key of that value ie "meta.enum.ShipmentStatus.Loaded".但我想从值中读取键,即从用户/客户端视图我得到“加载”值,我想读取该值的键,即“meta.enum.ShipmentStatus.Loaded”。
How to achieve this?如何做到这一点?
You can read keys by loading all keys and values into a map.您可以通过将所有键和值加载到 map 来读取键。 If so,
如果是这样,
public <K, V> Stream<K> keys(Map<K, V> map, V value) {
return map
.entrySet()
.stream()
.filter(entry -> value.equals(entry.getValue()))
.map(Map.Entry::getKey); }
can return the keys for the value.可以返回值的键。 But, if you are using Spring look at: https://stackoverflow.com/a/34655571/11813364
但是,如果您使用的是 Spring,请查看: https://stackoverflow.com/a/34655571/11813364
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.