diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ExtendedServletRequestDataBinder.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ExtendedServletRequestDataBinder.java index 352862fb0e63..1c019f80dd62 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ExtendedServletRequestDataBinder.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ExtendedServletRequestDataBinder.java @@ -124,7 +124,7 @@ protected void addBindValues(MutablePropertyValues mpvs, ServletRequest request) String name = names.nextElement(); Object value = getHeaderValue(httpRequest, name); if (value != null) { - name = StringUtils.uncapitalize(name.replace("-", "")); + name = transformedHeaderName(name); addValueIfNotPresent(mpvs, "Header", name, value); } } @@ -147,6 +147,10 @@ private static void addValueIfNotPresent(MutablePropertyValues mpvs, String labe } } + private static String transformedHeaderName(String headerName) { + return StringUtils.uncapitalize(headerName.replace("-", "")); + } + private @Nullable Object getHeaderValue(HttpServletRequest request, String name) { if (!this.headerPredicate.test(name)) { return null; @@ -206,7 +210,7 @@ protected Set initParameterNames(ServletRequest request) { Enumeration enumeration = httpServletRequest.getHeaderNames(); while (enumeration.hasMoreElements()) { String headerName = enumeration.nextElement(); - set.add(headerName.replaceAll("-", "")); + set.add(transformedHeaderName(headerName)); } } return set;