@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2023 the original author or authors .
* Copyright 2002 - 2024 the original author or authors .
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -18,7 +18,6 @@ package org.springframework.web.reactive;
@@ -18,7 +18,6 @@ package org.springframework.web.reactive;
import java.lang.annotation.Annotation ;
import java.util.Collection ;
import java.util.Collections ;
import java.util.Map ;
import reactor.core.publisher.Mono ;
@ -29,6 +28,7 @@ import org.springframework.core.ReactiveAdapterRegistry;
@@ -29,6 +28,7 @@ import org.springframework.core.ReactiveAdapterRegistry;
import org.springframework.core.ResolvableType ;
import org.springframework.lang.Nullable ;
import org.springframework.ui.Model ;
import org.springframework.util.CollectionUtils ;
import org.springframework.validation.BindingResult ;
import org.springframework.validation.DataBinder ;
import org.springframework.validation.SmartValidator ;
@ -209,10 +209,29 @@ public class BindingContext {
@@ -209,10 +209,29 @@ public class BindingContext {
@Override
public Mono < Map < String , Object > > getValuesToBind ( ServerWebExchange exchange ) {
return super . getValuesToBind ( exchange ) . doOnNext ( map - >
map . putAll ( exchange . < Map < String , String > > getAttributeOrDefault (
HandlerMapping . URI_TEMPLATE_VARIABLES_ATTRIBUTE , Collections . emptyMap ( ) ) ) ) ;
return super . getValuesToBind ( exchange ) . doOnNext ( map - > {
Map < String , String > vars = exchange . getAttribute ( HandlerMapping . URI_TEMPLATE_VARIABLES_ATTRIBUTE ) ;
if ( ! CollectionUtils . isEmpty ( vars ) ) {
vars . forEach ( ( key , value ) - > addValueIfNotPresent ( map , "URI variable" , key , value ) ) ;
}
} ) ;
}
private static void addValueIfNotPresent (
Map < String , Object > map , String label , String name , @Nullable Object value ) {
if ( value ! = null ) {
if ( map . containsKey ( name ) ) {
if ( logger . isDebugEnabled ( ) ) {
logger . debug ( label + " '" + name + "' overridden by request bind value." ) ;
}
}
else {
map . put ( name , value ) ;
}
}
}
}