foreach not applicable to type 'java.util.Map<java.lang.String,java.lang.Object>'
时间: 2024-05-14 10:17:44 浏览: 370
在JSTL EL中处理java.util.Map,及嵌套List的情况
`foreach` is not applicable to `Map` in Java. You can use `Map.entrySet()` to iterate through the key-value pairs of a map. Here’s an example:
```
Map<String, Object> map = new HashMap<>();
map.put("key1", "value1");
map.put("key2", "value2");
for(Map.Entry<String, Object> entry : map.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
System.out.println(key + " : " + value);
}
```
This will output:
```
key1 : value1
key2 : value2
```
You can replace the `System.out.println()` statement with your own logic to process each key-value pair.
阅读全文