Iteration over a map using EntrySet

This commit is contained in:
stsypanov
2019-05-13 14:27:01 +03:00
committed by Juergen Hoeller
parent 785e8d8116
commit 9ca8681f79
10 changed files with 45 additions and 36 deletions

View File

@@ -213,9 +213,9 @@ public class WebContentInterceptor extends WebContentGenerator implements Handle
return cacheControl;
}
// Pattern match?
for (String registeredPath : this.cacheControlMappings.keySet()) {
if (this.pathMatcher.match(registeredPath, urlPath)) {
return this.cacheControlMappings.get(registeredPath);
for (Map.Entry<String, CacheControl> entry : this.cacheControlMappings.entrySet()) {
if (this.pathMatcher.match(entry.getKey(), urlPath)) {
return entry.getValue();
}
}
return null;
@@ -238,9 +238,9 @@ public class WebContentInterceptor extends WebContentGenerator implements Handle
return cacheSeconds;
}
// Pattern match?
for (String registeredPath : this.cacheMappings.keySet()) {
if (this.pathMatcher.match(registeredPath, urlPath)) {
return this.cacheMappings.get(registeredPath);
for (Map.Entry<String, Integer> entry : this.cacheMappings.entrySet()) {
if (this.pathMatcher.match(entry.getKey(), urlPath)) {
return entry.getValue();
}
}
return null;

View File

@@ -19,6 +19,7 @@ package org.springframework.web.servlet.support;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -169,12 +170,12 @@ public abstract class AbstractFlashMapManager implements FlashMapManager {
}
MultiValueMap<String, String> actualParams = getOriginatingRequestParams(request);
MultiValueMap<String, String> expectedParams = flashMap.getTargetRequestParams();
for (String expectedName : expectedParams.keySet()) {
List<String> actualValues = actualParams.get(expectedName);
for (Map.Entry<String, List<String>> entry : expectedParams.entrySet()) {
List<String> actualValues = actualParams.get(entry.getKey());
if (actualValues == null) {
return false;
}
for (String expectedValue : expectedParams.get(expectedName)) {
for (String expectedValue : entry.getValue()) {
if (!actualValues.contains(expectedValue)) {
return false;
}

View File

@@ -485,8 +485,8 @@ public abstract class AbstractHtmlElementTag extends AbstractDataBoundFormElemen
writeOptionalAttribute(tagWriter, ONKEYDOWN_ATTRIBUTE, getOnkeydown());
if (!CollectionUtils.isEmpty(this.dynamicAttributes)) {
for (String attr : this.dynamicAttributes.keySet()) {
tagWriter.writeOptionalAttributeValue(attr, getDisplayString(this.dynamicAttributes.get(attr)));
for (Map.Entry<String, Object> entry : this.dynamicAttributes.entrySet()) {
tagWriter.writeOptionalAttributeValue(entry.getKey(), getDisplayString(entry.getValue()));
}
}
}

View File

@@ -704,9 +704,9 @@ public class FormTag extends AbstractHtmlElementTag {
if (!CollectionUtils.isEmpty(hiddenFields)) {
Assert.state(this.tagWriter != null, "No TagWriter set");
this.tagWriter.appendValue("<div>\n");
for (String name : hiddenFields.keySet()) {
for (Map.Entry<String, String> entry : hiddenFields.entrySet()) {
this.tagWriter.appendValue("<input type=\"hidden\" ");
this.tagWriter.appendValue("name=\"" + name + "\" value=\"" + hiddenFields.get(name) + "\" ");
this.tagWriter.appendValue("name=\"" + entry.getKey() + "\" value=\"" + entry.getValue() + "\" ");
this.tagWriter.appendValue("/>\n");
}
this.tagWriter.appendValue("</div>");