Support Optional without @RequestParam in WebFlux

The java.util.Optional wrapper should not affect the support for
"request param" arguments with or without the annotation as it
works on the Spring MVC side.
This commit is contained in:
Rossen Stoyanchev 2017-04-07 16:51:55 -04:00
parent 3780d040ee
commit 91977c81ad
2 changed files with 5 additions and 8 deletions

View File

@ -82,7 +82,8 @@ public class RequestParamMethodArgumentResolver extends AbstractNamedValueSyncAr
return true;
}
else if (this.useDefaultResolution) {
return checkParameterTypeNoReactiveWrapper(param, BeanUtils::isSimpleProperty);
return checkParameterTypeNoReactiveWrapper(param, BeanUtils::isSimpleProperty) ||
BeanUtils.isSimpleProperty(param.nestedIfOptional().getNestedParameterType());
}
return false;
}

View File

@ -22,7 +22,6 @@ import java.net.URI;
import java.util.Optional;
import org.junit.Test;
import reactor.core.publisher.Mono;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
@ -37,7 +36,6 @@ import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.reactive.config.EnableWebFlux;
import org.springframework.web.reactive.config.ViewResolverRegistry;
@ -126,9 +124,7 @@ public class RequestMappingViewResolutionIntegrationTests extends AbstractReques
private static class TestController {
@GetMapping("/html")
public String getHtmlPage(@RequestParam Optional<String> name, Model model,
ServerWebExchange exchange) {
public String getHtmlPage(Optional<String> name, Model model, ServerWebExchange exchange) {
if (exchange.checkNotModified("deadb33f8badf00d")) {
return null;
}
@ -137,8 +133,8 @@ public class RequestMappingViewResolutionIntegrationTests extends AbstractReques
}
@GetMapping("/redirect")
public Mono<String> redirect() {
return Mono.just("redirect:/");
public String redirect() {
return "redirect:/";
}
}