![](/img/trans.png)
[英]How to remove comma from a number being dynamically inserted in the value of a key in the properties file / resource bundle?
[英]How to read key from value of resource bundle/properties file
我有messages.properties捆綁文件,其中包含鍵、值對中的標簽,例如
meta.enum.ShipmentStatus.Loaded=Loaded
但我想從值中讀取鍵,即從用戶/客戶端視圖我得到“加載”值,我想讀取該值的鍵,即“meta.enum.ShipmentStatus.Loaded”。
如何做到這一點?
您可以通過將所有鍵和值加載到 map 來讀取鍵。 如果是這樣,
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); }
可以返回值的鍵。 但是,如果您使用的是 Spring,請查看: https://stackoverflow.com/a/34655571/11813364
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.