Skip to content

Commit 37db3ba

Browse files
committed
Polishing
(cherry picked from commit 6027cf2)
1 parent 4b2a047 commit 37db3ba

File tree

4 files changed

+38
-40
lines changed

4 files changed

+38
-40
lines changed

spring-web/src/main/java/org/springframework/web/method/support/ModelAndViewContainer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -172,9 +172,9 @@ public ModelMap getDefaultModel() {
172172

173173
/**
174174
* Provide a separate model instance to use in a redirect scenario.
175-
* The provided additional model however is not used unless
176-
* {@link #setRedirectModelScenario(boolean)} gets set to {@code true} to signal
177-
* a redirect scenario.
175+
* <p>The provided additional model however is not used unless
176+
* {@link #setRedirectModelScenario} gets set to {@code true}
177+
* to signal an actual redirect scenario.
178178
*/
179179
public void setRedirectModel(ModelMap redirectModel) {
180180
this.redirectModel = redirectModel;

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/support/DefaultHandlerExceptionResolver.java

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ else if (ex instanceof AsyncRequestTimeoutException) {
247247
* @param handler the executed handler, or {@code null} if none chosen
248248
* at the time of the exception (for example, if multipart resolution failed)
249249
* @return an empty ModelAndView indicating the exception was handled
250-
* @throws IOException potentially thrown from response.sendError()
250+
* @throws IOException potentially thrown from {@link HttpServletResponse#sendError}
251251
*/
252252
protected ModelAndView handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException ex,
253253
HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws IOException {
@@ -272,7 +272,7 @@ protected ModelAndView handleHttpRequestMethodNotSupported(HttpRequestMethodNotS
272272
* @param response current HTTP response
273273
* @param handler the executed handler
274274
* @return an empty ModelAndView indicating the exception was handled
275-
* @throws IOException potentially thrown from response.sendError()
275+
* @throws IOException potentially thrown from {@link HttpServletResponse#sendError}
276276
*/
277277
protected ModelAndView handleHttpMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex,
278278
HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws IOException {
@@ -296,7 +296,7 @@ protected ModelAndView handleHttpMediaTypeNotSupported(HttpMediaTypeNotSupported
296296
* @param response current HTTP response
297297
* @param handler the executed handler
298298
* @return an empty ModelAndView indicating the exception was handled
299-
* @throws IOException potentially thrown from response.sendError()
299+
* @throws IOException potentially thrown from {@link HttpServletResponse#sendError}
300300
*/
301301
protected ModelAndView handleHttpMediaTypeNotAcceptable(HttpMediaTypeNotAcceptableException ex,
302302
HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws IOException {
@@ -315,7 +315,7 @@ protected ModelAndView handleHttpMediaTypeNotAcceptable(HttpMediaTypeNotAcceptab
315315
* @param response current HTTP response
316316
* @param handler the executed handler
317317
* @return an empty ModelAndView indicating the exception was handled
318-
* @throws IOException potentially thrown from response.sendError()
318+
* @throws IOException potentially thrown from {@link HttpServletResponse#sendError}
319319
* @since 4.2
320320
*/
321321
protected ModelAndView handleMissingPathVariable(MissingPathVariableException ex,
@@ -335,7 +335,7 @@ protected ModelAndView handleMissingPathVariable(MissingPathVariableException ex
335335
* @param response current HTTP response
336336
* @param handler the executed handler
337337
* @return an empty ModelAndView indicating the exception was handled
338-
* @throws IOException potentially thrown from response.sendError()
338+
* @throws IOException potentially thrown from {@link HttpServletResponse#sendError}
339339
*/
340340
protected ModelAndView handleMissingServletRequestParameter(MissingServletRequestParameterException ex,
341341
HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws IOException {
@@ -353,7 +353,7 @@ protected ModelAndView handleMissingServletRequestParameter(MissingServletReques
353353
* @param response current HTTP response
354354
* @param handler the executed handler
355355
* @return an empty ModelAndView indicating the exception was handled
356-
* @throws IOException potentially thrown from response.sendError()
356+
* @throws IOException potentially thrown from {@link HttpServletResponse#sendError}
357357
*/
358358
protected ModelAndView handleServletRequestBindingException(ServletRequestBindingException ex,
359359
HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws IOException {
@@ -371,7 +371,7 @@ protected ModelAndView handleServletRequestBindingException(ServletRequestBindin
371371
* @param response current HTTP response
372372
* @param handler the executed handler
373373
* @return an empty ModelAndView indicating the exception was handled
374-
* @throws IOException potentially thrown from response.sendError()
374+
* @throws IOException potentially thrown from {@link HttpServletResponse#sendError}
375375
*/
376376
protected ModelAndView handleConversionNotSupported(ConversionNotSupportedException ex,
377377
HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws IOException {
@@ -392,7 +392,7 @@ protected ModelAndView handleConversionNotSupported(ConversionNotSupportedExcept
392392
* @param response current HTTP response
393393
* @param handler the executed handler
394394
* @return an empty ModelAndView indicating the exception was handled
395-
* @throws IOException potentially thrown from response.sendError()
395+
* @throws IOException potentially thrown from {@link HttpServletResponse#sendError}
396396
*/
397397
protected ModelAndView handleTypeMismatch(TypeMismatchException ex,
398398
HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws IOException {
@@ -415,7 +415,7 @@ protected ModelAndView handleTypeMismatch(TypeMismatchException ex,
415415
* @param response current HTTP response
416416
* @param handler the executed handler
417417
* @return an empty ModelAndView indicating the exception was handled
418-
* @throws IOException potentially thrown from response.sendError()
418+
* @throws IOException potentially thrown from {@link HttpServletResponse#sendError}
419419
*/
420420
protected ModelAndView handleHttpMessageNotReadable(HttpMessageNotReadableException ex,
421421
HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws IOException {
@@ -428,17 +428,18 @@ protected ModelAndView handleHttpMessageNotReadable(HttpMessageNotReadableExcept
428428
}
429429

430430
/**
431-
* Handle the case where a {@linkplain org.springframework.http.converter.HttpMessageConverter message converter}
431+
* Handle the case where a
432+
* {@linkplain org.springframework.http.converter.HttpMessageConverter message converter}
432433
* cannot write to a HTTP request.
433434
* <p>The default implementation sends an HTTP 500 error, and returns an empty {@code ModelAndView}.
434-
* Alternatively, a fallback view could be chosen, or the HttpMediaTypeNotSupportedException could be
435-
* rethrown as-is.
435+
* Alternatively, a fallback view could be chosen, or the HttpMediaTypeNotSupportedException could
436+
* be rethrown as-is.
436437
* @param ex the HttpMessageNotWritableException to be handled
437438
* @param request current HTTP request
438439
* @param response current HTTP response
439440
* @param handler the executed handler
440441
* @return an empty ModelAndView indicating the exception was handled
441-
* @throws IOException potentially thrown from response.sendError()
442+
* @throws IOException potentially thrown from {@link HttpServletResponse#sendError}
442443
*/
443444
protected ModelAndView handleHttpMessageNotWritable(HttpMessageNotWritableException ex,
444445
HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws IOException {
@@ -453,12 +454,12 @@ protected ModelAndView handleHttpMessageNotWritable(HttpMessageNotWritableExcept
453454
/**
454455
* Handle the case where an argument annotated with {@code @Valid} such as
455456
* an {@link RequestBody} or {@link RequestPart} argument fails validation.
456-
* An HTTP 400 error is sent back to the client.
457+
* <p>By default, an HTTP 400 error is sent back to the client.
457458
* @param request current HTTP request
458459
* @param response current HTTP response
459460
* @param handler the executed handler
460461
* @return an empty ModelAndView indicating the exception was handled
461-
* @throws IOException potentially thrown from response.sendError()
462+
* @throws IOException potentially thrown from {@link HttpServletResponse#sendError}
462463
*/
463464
protected ModelAndView handleMethodArgumentNotValidException(MethodArgumentNotValidException ex,
464465
HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws IOException {
@@ -470,12 +471,12 @@ protected ModelAndView handleMethodArgumentNotValidException(MethodArgumentNotVa
470471
/**
471472
* Handle the case where an {@linkplain RequestPart @RequestPart}, a {@link MultipartFile},
472473
* or a {@code javax.servlet.http.Part} argument is required but is missing.
473-
* An HTTP 400 error is sent back to the client.
474+
* <p>By default, an HTTP 400 error is sent back to the client.
474475
* @param request current HTTP request
475476
* @param response current HTTP response
476477
* @param handler the executed handler
477478
* @return an empty ModelAndView indicating the exception was handled
478-
* @throws IOException potentially thrown from response.sendError()
479+
* @throws IOException potentially thrown from {@link HttpServletResponse#sendError}
479480
*/
480481
protected ModelAndView handleMissingServletRequestPartException(MissingServletRequestPartException ex,
481482
HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) throws IOException {
@@ -488,12 +489,12 @@ protected ModelAndView handleMissingServletRequestPartException(MissingServletRe
488489
* Handle the case where an {@linkplain ModelAttribute @ModelAttribute} method
489490
* argument has binding or validation errors and is not followed by another
490491
* method argument of type {@link BindingResult}.
491-
* By default, an HTTP 400 error is sent back to the client.
492+
* <p>By default, an HTTP 400 error is sent back to the client.
492493
* @param request current HTTP request
493494
* @param response current HTTP response
494495
* @param handler the executed handler
495496
* @return an empty ModelAndView indicating the exception was handled
496-
* @throws IOException potentially thrown from response.sendError()
497+
* @throws IOException potentially thrown from {@link HttpServletResponse#sendError}
497498
*/
498499
protected ModelAndView handleBindException(BindException ex, HttpServletRequest request,
499500
HttpServletResponse response, @Nullable Object handler) throws IOException {
@@ -513,7 +514,7 @@ protected ModelAndView handleBindException(BindException ex, HttpServletRequest
513514
* @param handler the executed handler, or {@code null} if none chosen
514515
* at the time of the exception (for example, if multipart resolution failed)
515516
* @return an empty ModelAndView indicating the exception was handled
516-
* @throws IOException potentially thrown from response.sendError()
517+
* @throws IOException potentially thrown from {@link HttpServletResponse#sendError}
517518
* @since 4.0
518519
*/
519520
protected ModelAndView handleNoHandlerFoundException(NoHandlerFoundException ex,
@@ -532,7 +533,7 @@ protected ModelAndView handleNoHandlerFoundException(NoHandlerFoundException ex,
532533
* @param handler the executed handler, or {@code null} if none chosen
533534
* at the time of the exception (for example, if multipart resolution failed)
534535
* @return an empty ModelAndView indicating the exception was handled
535-
* @throws IOException potentially thrown from response.sendError()
536+
* @throws IOException potentially thrown from {@link HttpServletResponse#sendError}
536537
* @since 4.2.8
537538
*/
538539
protected ModelAndView handleAsyncRequestTimeoutException(AsyncRequestTimeoutException ex,

spring-webmvc/src/main/java/org/springframework/web/servlet/view/AbstractView.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -83,7 +83,7 @@ public abstract class AbstractView extends WebApplicationObjectSupport implement
8383

8484
@Nullable
8585
private Set<String> exposedContextBeanNames;
86-
86+
8787
@Nullable
8888
private String beanName;
8989

@@ -138,7 +138,8 @@ public void setAttributesCSV(@Nullable String propString) throws IllegalArgument
138138
String tok = st.nextToken();
139139
int eqIdx = tok.indexOf('=');
140140
if (eqIdx == -1) {
141-
throw new IllegalArgumentException("Expected = in attributes CSV string '" + propString + "'");
141+
throw new IllegalArgumentException(
142+
"Expected '=' in attributes CSV string '" + propString + "'");
142143
}
143144
if (eqIdx >= tok.length() - 2) {
144145
throw new IllegalArgumentException(
@@ -180,7 +181,7 @@ public void setAttributes(Properties attributes) {
180181
* the View instance configuration. "Dynamic" attributes, on the other hand,
181182
* are values passed in as part of the model.
182183
* <p>Can be populated with a "map" or "props" element in XML bean definitions.
183-
* @param attributes Map with name Strings as keys and attribute objects as values
184+
* @param attributes a Map with name Strings as keys and attribute objects as values
184185
*/
185186
public void setAttributesMap(@Nullable Map<String, ?> attributes) {
186187
if (attributes != null) {
@@ -431,7 +432,7 @@ protected abstract void renderMergedOutputModel(
431432
* Expose the model objects in the given map as request attributes.
432433
* Names will be taken from the model Map.
433434
* This method is suitable for all resources reachable by {@link javax.servlet.RequestDispatcher}.
434-
* @param model Map of model objects to expose
435+
* @param model a Map of model objects to expose
435436
* @param request current HTTP request
436437
*/
437438
protected void exposeModelAsRequestAttributes(Map<String, Object> model,

spring-webmvc/src/main/java/org/springframework/web/servlet/view/xml/MappingJackson2XmlView.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -42,9 +42,13 @@
4242
*
4343
* @author Sebastien Deleuze
4444
* @since 4.1
45+
* @see org.springframework.web.servlet.view.json.MappingJackson2JsonView
4546
*/
4647
public class MappingJackson2XmlView extends AbstractJackson2View {
4748

49+
/**
50+
* The default content type for the view.
51+
*/
4852
public static final String DEFAULT_CONTENT_TYPE = "application/xml";
4953

5054

@@ -70,20 +74,12 @@ public MappingJackson2XmlView(XmlMapper xmlMapper) {
7074
super(xmlMapper, DEFAULT_CONTENT_TYPE);
7175
}
7276

73-
/**
74-
* {@inheritDoc}
75-
*/
77+
7678
@Override
7779
public void setModelKey(String modelKey) {
7880
this.modelKey = modelKey;
7981
}
8082

81-
/**
82-
* Filter out undesired attributes from the given model.
83-
* The return value can be either another {@link Map} or a single value object.
84-
* @param model the model, as passed on to {@link #renderMergedOutputModel}
85-
* @return the value to be rendered
86-
*/
8783
@Override
8884
protected Object filterModel(Map<String, Object> model) {
8985
Object value = null;

0 commit comments

Comments
 (0)