Consistent support for java.util.Optional for all applicable handler method arguments

Issue: SPR-12171
This commit is contained in:
Juergen Hoeller
2014-09-10 01:27:46 +02:00
parent 559e81bec7
commit 5790fc904a
8 changed files with 83 additions and 51 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 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.
@@ -114,12 +114,9 @@ public class MatrixVariableMethodArgumentResolver extends AbstractNamedValueMeth
}
@Override
protected void handleMissingValue(String name, MethodParameter param) throws ServletRequestBindingException {
Class<?> paramType = param.getParameterType();
if (!paramType.getName().equals("java.util.Optional")) {
throw new ServletRequestBindingException(
"Missing matrix variable '" + name + "' for method parameter type [" + paramType.getName() + "]");
}
protected void handleMissingValue(String name, MethodParameter parameter) throws ServletRequestBindingException {
throw new ServletRequestBindingException("Missing matrix variable '" + name +
"' for method parameter type " + parameter.getParameterType().getSimpleName());
}

View File

@@ -101,10 +101,9 @@ public class PathVariableMethodArgumentResolver extends AbstractNamedValueMethod
}
@Override
protected void handleMissingValue(String name, MethodParameter param) throws ServletRequestBindingException {
String paramType = param.getParameterType().getName();
throw new ServletRequestBindingException(
"Missing URI template variable '" + name + "' for method parameter type [" + paramType + "]");
protected void handleMissingValue(String name, MethodParameter parameter) throws ServletRequestBindingException {
throw new ServletRequestBindingException("Missing URI template variable '" + name +
"' for method parameter type " + parameter.getParameterType().getSimpleName());
}
@Override