Skip to content

Commit 7a97ba5

Browse files
committed
Polishing
1 parent 9de85f1 commit 7a97ba5

File tree

4 files changed

+40
-41
lines changed

4 files changed

+40
-41
lines changed

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

Lines changed: 5 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.
@@ -43,6 +43,7 @@
4343
* returns the redirect model instead of the default model.
4444
*
4545
* @author Rossen Stoyanchev
46+
* @author Juergen Hoeller
4647
* @since 3.1
4748
*/
4849
public class ModelAndViewContainer {
@@ -165,9 +166,9 @@ public ModelMap getDefaultModel() {
165166

166167
/**
167168
* Provide a separate model instance to use in a redirect scenario.
168-
* The provided additional model however is not used unless
169-
* {@link #setRedirectModelScenario(boolean)} gets set to {@code true} to signal
170-
* a redirect scenario.
169+
* <p>The provided additional model however is not used unless
170+
* {@link #setRedirectModelScenario} gets set to {@code true}
171+
* to signal an actual redirect scenario.
171172
*/
172173
public void setRedirectModel(ModelMap redirectModel) {
173174
this.redirectModel = redirectModel;

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

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ else if (ex instanceof AsyncRequestTimeoutException) {
190190
* @param handler the executed handler, or {@code null} if none chosen
191191
* at the time of the exception (for example, if multipart resolution failed)
192192
* @return an empty ModelAndView indicating the exception was handled
193-
* @throws IOException potentially thrown from response.sendError()
193+
* @throws IOException potentially thrown from {@link HttpServletResponse#sendError}
194194
* @deprecated as of 4.3, along with {@link org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException}
195195
*/
196196
@Deprecated
@@ -213,7 +213,7 @@ protected ModelAndView handleNoSuchRequestHandlingMethod(org.springframework.web
213213
* @param handler the executed handler, or {@code null} if none chosen
214214
* at the time of the exception (for example, if multipart resolution failed)
215215
* @return an empty ModelAndView indicating the exception was handled
216-
* @throws IOException potentially thrown from response.sendError()
216+
* @throws IOException potentially thrown from {@link HttpServletResponse#sendError}
217217
*/
218218
protected ModelAndView handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException ex,
219219
HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {
@@ -238,7 +238,7 @@ protected ModelAndView handleHttpRequestMethodNotSupported(HttpRequestMethodNotS
238238
* @param response current HTTP response
239239
* @param handler the executed handler
240240
* @return an empty ModelAndView indicating the exception was handled
241-
* @throws IOException potentially thrown from response.sendError()
241+
* @throws IOException potentially thrown from {@link HttpServletResponse#sendError}
242242
*/
243243
protected ModelAndView handleHttpMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex,
244244
HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {
@@ -262,7 +262,7 @@ protected ModelAndView handleHttpMediaTypeNotSupported(HttpMediaTypeNotSupported
262262
* @param response current HTTP response
263263
* @param handler the executed handler
264264
* @return an empty ModelAndView indicating the exception was handled
265-
* @throws IOException potentially thrown from response.sendError()
265+
* @throws IOException potentially thrown from {@link HttpServletResponse#sendError}
266266
*/
267267
protected ModelAndView handleHttpMediaTypeNotAcceptable(HttpMediaTypeNotAcceptableException ex,
268268
HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {
@@ -281,7 +281,7 @@ protected ModelAndView handleHttpMediaTypeNotAcceptable(HttpMediaTypeNotAcceptab
281281
* @param response current HTTP response
282282
* @param handler the executed handler
283283
* @return an empty ModelAndView indicating the exception was handled
284-
* @throws IOException potentially thrown from response.sendError()
284+
* @throws IOException potentially thrown from {@link HttpServletResponse#sendError}
285285
* @since 4.2
286286
*/
287287
protected ModelAndView handleMissingPathVariable(MissingPathVariableException ex,
@@ -301,7 +301,7 @@ protected ModelAndView handleMissingPathVariable(MissingPathVariableException ex
301301
* @param response current HTTP response
302302
* @param handler the executed handler
303303
* @return an empty ModelAndView indicating the exception was handled
304-
* @throws IOException potentially thrown from response.sendError()
304+
* @throws IOException potentially thrown from {@link HttpServletResponse#sendError}
305305
*/
306306
protected ModelAndView handleMissingServletRequestParameter(MissingServletRequestParameterException ex,
307307
HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {
@@ -319,7 +319,7 @@ protected ModelAndView handleMissingServletRequestParameter(MissingServletReques
319319
* @param response current HTTP response
320320
* @param handler the executed handler
321321
* @return an empty ModelAndView indicating the exception was handled
322-
* @throws IOException potentially thrown from response.sendError()
322+
* @throws IOException potentially thrown from {@link HttpServletResponse#sendError}
323323
*/
324324
protected ModelAndView handleServletRequestBindingException(ServletRequestBindingException ex,
325325
HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {
@@ -337,7 +337,7 @@ protected ModelAndView handleServletRequestBindingException(ServletRequestBindin
337337
* @param response current HTTP response
338338
* @param handler the executed handler
339339
* @return an empty ModelAndView indicating the exception was handled
340-
* @throws IOException potentially thrown from response.sendError()
340+
* @throws IOException potentially thrown from {@link HttpServletResponse#sendError}
341341
*/
342342
protected ModelAndView handleConversionNotSupported(ConversionNotSupportedException ex,
343343
HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {
@@ -358,7 +358,7 @@ protected ModelAndView handleConversionNotSupported(ConversionNotSupportedExcept
358358
* @param response current HTTP response
359359
* @param handler the executed handler
360360
* @return an empty ModelAndView indicating the exception was handled
361-
* @throws IOException potentially thrown from response.sendError()
361+
* @throws IOException potentially thrown from {@link HttpServletResponse#sendError}
362362
*/
363363
protected ModelAndView handleTypeMismatch(TypeMismatchException ex,
364364
HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {
@@ -381,7 +381,7 @@ protected ModelAndView handleTypeMismatch(TypeMismatchException ex,
381381
* @param response current HTTP response
382382
* @param handler the executed handler
383383
* @return an empty ModelAndView indicating the exception was handled
384-
* @throws IOException potentially thrown from response.sendError()
384+
* @throws IOException potentially thrown from {@link HttpServletResponse#sendError}
385385
*/
386386
protected ModelAndView handleHttpMessageNotReadable(HttpMessageNotReadableException ex,
387387
HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {
@@ -394,17 +394,18 @@ protected ModelAndView handleHttpMessageNotReadable(HttpMessageNotReadableExcept
394394
}
395395

396396
/**
397-
* Handle the case where a {@linkplain org.springframework.http.converter.HttpMessageConverter message converter}
397+
* Handle the case where a
398+
* {@linkplain org.springframework.http.converter.HttpMessageConverter message converter}
398399
* cannot write to a HTTP request.
399400
* <p>The default implementation sends an HTTP 500 error, and returns an empty {@code ModelAndView}.
400-
* Alternatively, a fallback view could be chosen, or the HttpMediaTypeNotSupportedException could be
401-
* rethrown as-is.
401+
* Alternatively, a fallback view could be chosen, or the HttpMediaTypeNotSupportedException could
402+
* be rethrown as-is.
402403
* @param ex the HttpMessageNotWritableException to be handled
403404
* @param request current HTTP request
404405
* @param response current HTTP response
405406
* @param handler the executed handler
406407
* @return an empty ModelAndView indicating the exception was handled
407-
* @throws IOException potentially thrown from response.sendError()
408+
* @throws IOException potentially thrown from {@link HttpServletResponse#sendError}
408409
*/
409410
protected ModelAndView handleHttpMessageNotWritable(HttpMessageNotWritableException ex,
410411
HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {
@@ -419,29 +420,29 @@ protected ModelAndView handleHttpMessageNotWritable(HttpMessageNotWritableExcept
419420
/**
420421
* Handle the case where an argument annotated with {@code @Valid} such as
421422
* an {@link RequestBody} or {@link RequestPart} argument fails validation.
422-
* An HTTP 400 error is sent back to the client.
423+
* <p>By default, an HTTP 400 error is sent back to the client.
423424
* @param request current HTTP request
424425
* @param response current HTTP response
425426
* @param handler the executed handler
426427
* @return an empty ModelAndView indicating the exception was handled
427-
* @throws IOException potentially thrown from response.sendError()
428+
* @throws IOException potentially thrown from {@link HttpServletResponse#sendError}
428429
*/
429430
protected ModelAndView handleMethodArgumentNotValidException(MethodArgumentNotValidException ex,
430431
HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {
431432

432-
response.sendError(HttpServletResponse.SC_BAD_REQUEST);
433+
response.sendError(HttpServletResponse.SC_BAD_REQUEST);
433434
return new ModelAndView();
434435
}
435436

436437
/**
437438
* Handle the case where an {@linkplain RequestPart @RequestPart}, a {@link MultipartFile},
438439
* or a {@code javax.servlet.http.Part} argument is required but is missing.
439-
* An HTTP 400 error is sent back to the client.
440+
* <p>By default, an HTTP 400 error is sent back to the client.
440441
* @param request current HTTP request
441442
* @param response current HTTP response
442443
* @param handler the executed handler
443444
* @return an empty ModelAndView indicating the exception was handled
444-
* @throws IOException potentially thrown from response.sendError()
445+
* @throws IOException potentially thrown from {@link HttpServletResponse#sendError}
445446
*/
446447
protected ModelAndView handleMissingServletRequestPartException(MissingServletRequestPartException ex,
447448
HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {
@@ -454,12 +455,12 @@ protected ModelAndView handleMissingServletRequestPartException(MissingServletRe
454455
* Handle the case where an {@linkplain ModelAttribute @ModelAttribute} method
455456
* argument has binding or validation errors and is not followed by another
456457
* method argument of type {@link BindingResult}.
457-
* By default, an HTTP 400 error is sent back to the client.
458+
* <p>By default, an HTTP 400 error is sent back to the client.
458459
* @param request current HTTP request
459460
* @param response current HTTP response
460461
* @param handler the executed handler
461462
* @return an empty ModelAndView indicating the exception was handled
462-
* @throws IOException potentially thrown from response.sendError()
463+
* @throws IOException potentially thrown from {@link HttpServletResponse#sendError}
463464
*/
464465
protected ModelAndView handleBindException(BindException ex, HttpServletRequest request,
465466
HttpServletResponse response, Object handler) throws IOException {
@@ -479,7 +480,7 @@ protected ModelAndView handleBindException(BindException ex, HttpServletRequest
479480
* @param handler the executed handler, or {@code null} if none chosen
480481
* at the time of the exception (for example, if multipart resolution failed)
481482
* @return an empty ModelAndView indicating the exception was handled
482-
* @throws IOException potentially thrown from response.sendError()
483+
* @throws IOException potentially thrown from {@link HttpServletResponse#sendError}
483484
* @since 4.0
484485
*/
485486
protected ModelAndView handleNoHandlerFoundException(NoHandlerFoundException ex,
@@ -498,7 +499,7 @@ protected ModelAndView handleNoHandlerFoundException(NoHandlerFoundException ex,
498499
* @param handler the executed handler, or {@code null} if none chosen
499500
* at the time of the exception (for example, if multipart resolution failed)
500501
* @return an empty ModelAndView indicating the exception was handled
501-
* @throws IOException potentially thrown from response.sendError()
502+
* @throws IOException potentially thrown from {@link HttpServletResponse#sendError}
502503
* @since 4.2.8
503504
*/
504505
protected ModelAndView handleAsyncRequestTimeoutException(AsyncRequestTimeoutException ex,

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

Lines changed: 5 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.
@@ -128,7 +128,8 @@ public void setAttributesCSV(String propString) throws IllegalArgumentException
128128
String tok = st.nextToken();
129129
int eqIdx = tok.indexOf('=');
130130
if (eqIdx == -1) {
131-
throw new IllegalArgumentException("Expected = in attributes CSV string '" + propString + "'");
131+
throw new IllegalArgumentException(
132+
"Expected '=' in attributes CSV string '" + propString + "'");
132133
}
133134
if (eqIdx >= tok.length() - 2) {
134135
throw new IllegalArgumentException(
@@ -170,7 +171,7 @@ public void setAttributes(Properties attributes) {
170171
* the View instance configuration. "Dynamic" attributes, on the other hand,
171172
* are values passed in as part of the model.
172173
* <p>Can be populated with a "map" or "props" element in XML bean definitions.
173-
* @param attributes Map with name Strings as keys and attribute objects as values
174+
* @param attributes a Map with name Strings as keys and attribute objects as values
174175
*/
175176
public void setAttributesMap(Map<String, ?> attributes) {
176177
if (attributes != null) {
@@ -419,7 +420,7 @@ protected abstract void renderMergedOutputModel(
419420
* Expose the model objects in the given map as request attributes.
420421
* Names will be taken from the model Map.
421422
* This method is suitable for all resources reachable by {@link javax.servlet.RequestDispatcher}.
422-
* @param model Map of model objects to expose
423+
* @param model a Map of model objects to expose
423424
* @param request current HTTP request
424425
*/
425426
protected void exposeModelAsRequestAttributes(Map<String, Object> model, HttpServletRequest request) throws Exception {

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-2015 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.
@@ -40,9 +40,13 @@
4040
*
4141
* @author Sebastien Deleuze
4242
* @since 4.1
43+
* @see org.springframework.web.servlet.view.json.MappingJackson2JsonView
4344
*/
4445
public class MappingJackson2XmlView extends AbstractJackson2View {
4546

47+
/**
48+
* The default content type for the view.
49+
*/
4650
public static final String DEFAULT_CONTENT_TYPE = "application/xml";
4751

4852

@@ -67,20 +71,12 @@ public MappingJackson2XmlView(XmlMapper xmlMapper) {
6771
super(xmlMapper, DEFAULT_CONTENT_TYPE);
6872
}
6973

70-
/**
71-
* {@inheritDoc}
72-
*/
74+
7375
@Override
7476
public void setModelKey(String modelKey) {
7577
this.modelKey = modelKey;
7678
}
7779

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

0 commit comments

Comments
 (0)