Skip to content

Commit eb97335

Browse files
committed
Polishing
1 parent 0028b29 commit eb97335

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

spring-web/src/main/java/org/springframework/web/method/annotation/AbstractNamedValueMethodArgumentResolver.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,19 @@
3939
* Abstract base class for resolving method arguments from a named value.
4040
* Request parameters, request headers, and path variables are examples of named
4141
* values. Each may have a name, a required flag, and a default value.
42+
*
4243
* <p>Subclasses define how to do the following:
4344
* <ul>
4445
* <li>Obtain named value information for a method parameter
4546
* <li>Resolve names into argument values
4647
* <li>Handle missing argument values when argument values are required
4748
* <li>Optionally handle a resolved value
4849
* </ul>
50+
*
4951
* <p>A default value string can contain ${...} placeholders and Spring Expression
5052
* Language #{...} expressions. For this to work a
5153
* {@link ConfigurableBeanFactory} must be supplied to the class constructor.
54+
*
5255
* <p>A {@link WebDataBinder} is created to apply type conversion to the resolved
5356
* argument value if it doesn't match the method parameter type.
5457
*
@@ -63,7 +66,8 @@ public abstract class AbstractNamedValueMethodArgumentResolver implements Handle
6366

6467
private final BeanExpressionContext expressionContext;
6568

66-
private final Map<MethodParameter, NamedValueInfo> namedValueInfoCache = new ConcurrentHashMap<MethodParameter, NamedValueInfo>(256);
69+
private final Map<MethodParameter, NamedValueInfo> namedValueInfoCache =
70+
new ConcurrentHashMap<MethodParameter, NamedValueInfo>(256);
6771

6872

6973
public AbstractNamedValueMethodArgumentResolver() {
@@ -78,7 +82,8 @@ public AbstractNamedValueMethodArgumentResolver() {
7882
*/
7983
public AbstractNamedValueMethodArgumentResolver(ConfigurableBeanFactory beanFactory) {
8084
this.configurableBeanFactory = beanFactory;
81-
this.expressionContext = (beanFactory != null ? new BeanExpressionContext(beanFactory, new RequestScope()) : null);
85+
this.expressionContext =
86+
(beanFactory != null ? new BeanExpressionContext(beanFactory, new RequestScope()) : null);
8287
}
8388

8489

@@ -204,7 +209,9 @@ protected abstract Object resolveName(String name, MethodParameter parameter, Na
204209
* @param request the current request
205210
* @since 4.3
206211
*/
207-
protected void handleMissingValue(String name, MethodParameter parameter, NativeWebRequest request) throws Exception {
212+
protected void handleMissingValue(String name, MethodParameter parameter, NativeWebRequest request)
213+
throws Exception {
214+
208215
handleMissingValue(name, parameter);
209216
}
210217

@@ -241,7 +248,7 @@ else if (paramType.isPrimitive()) {
241248
* @param arg the resolved argument value
242249
* @param name the argument name
243250
* @param parameter the argument parameter type
244-
* @param mavContainer the {@link ModelAndViewContainer}, which may be {@code null}
251+
* @param mavContainer the {@link ModelAndViewContainer} (may be {@code null})
245252
* @param webRequest the current request
246253
*/
247254
protected void handleResolvedValue(Object arg, String name, MethodParameter parameter,

spring-web/src/main/java/org/springframework/web/method/annotation/RequestParamMethodArgumentResolver.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,9 @@ protected Object resolveName(String name, MethodParameter parameter, NativeWebRe
181181
}
182182

183183
@Override
184-
protected void handleMissingValue(String name, MethodParameter parameter, NativeWebRequest request) throws Exception {
184+
protected void handleMissingValue(String name, MethodParameter parameter, NativeWebRequest request)
185+
throws Exception {
186+
185187
HttpServletRequest servletRequest = request.getNativeRequest(HttpServletRequest.class);
186188
if (MultipartResolutionDelegate.isMultipartArgument(parameter)) {
187189
if (!MultipartResolutionDelegate.isMultipartRequest(servletRequest)) {
@@ -192,7 +194,8 @@ protected void handleMissingValue(String name, MethodParameter parameter, Native
192194
}
193195
}
194196
else {
195-
throw new MissingServletRequestParameterException(name, parameter.getNestedParameterType().getSimpleName());
197+
throw new MissingServletRequestParameterException(name,
198+
parameter.getNestedParameterType().getSimpleName());
196199
}
197200
}
198201

0 commit comments

Comments
 (0)