Support java.util.Optional for @MVC named value args
After this change, java.util.Optional is supported with @RequestParam, @RequestHeader, and @MatrixVariable arguments in Java 8. When Optional is used the required flag is effectively ignored. Issue: SPR-11829
This commit is contained in:
@@ -115,9 +115,11 @@ public class MatrixVariableMethodArgumentResolver extends AbstractNamedValueMeth
|
||||
|
||||
@Override
|
||||
protected void handleMissingValue(String name, MethodParameter param) throws ServletRequestBindingException {
|
||||
String paramType = param.getParameterType().getName();
|
||||
throw new ServletRequestBindingException(
|
||||
"Missing matrix variable '" + name + "' for method parameter type [" + paramType + "]");
|
||||
Class<?> paramType = param.getParameterType();
|
||||
if (!paramType.getName().equals("java.util.Optional")) {
|
||||
throw new ServletRequestBindingException(
|
||||
"Missing matrix variable '" + name + "' for method parameter type [" + paramType.getName() + "]");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user