Skip to content

Commit 6027cf2

Browse files
committed
Polishing
1 parent c0c9e08 commit 6027cf2

File tree

5 files changed

+33
-44
lines changed

5 files changed

+33
-44
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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/DispatcherServlet.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,6 @@ protected Object createDefaultStrategy(ApplicationContext context, Class<?> claz
906906
*/
907907
@Override
908908
protected void doService(HttpServletRequest request, HttpServletResponse response) throws Exception {
909-
910909
logRequest(request);
911910

912911
// Keep a snapshot of the request attributes in case of an include,
@@ -953,24 +952,21 @@ protected void doService(HttpServletRequest request, HttpServletResponse respons
953952

954953
private void logRequest(HttpServletRequest request) {
955954
if (logger.isDebugEnabled()) {
956-
957955
String params;
958956
if (isEnableLoggingRequestDetails()) {
959957
params = request.getParameterMap().entrySet().stream()
960958
.map(entry -> entry.getKey() + ":" + Arrays.toString(entry.getValue()))
961959
.collect(Collectors.joining(", "));
962960
}
963961
else {
964-
params = request.getParameterMap().isEmpty() ? "" : "masked";
962+
params = (request.getParameterMap().isEmpty() ? "" : "masked");
965963
}
966964

967965
String query = StringUtils.isEmpty(request.getQueryString()) ? "" : "?" + request.getQueryString();
968-
969-
String dispatchType = !request.getDispatcherType().equals(DispatcherType.REQUEST) ?
970-
"\"" + request.getDispatcherType().name() + "\" dispatch for " : "";
971-
972-
String message = dispatchType + request.getMethod() +
973-
" \"" + getRequestUri(request) + query + "\", parameters={" + params + "}";
966+
String dispatchType = (!request.getDispatcherType().equals(DispatcherType.REQUEST) ?
967+
"\"" + request.getDispatcherType().name() + "\" dispatch for " : "");
968+
String message = (dispatchType + request.getMethod() + " \"" + getRequestUri(request) +
969+
query + "\", parameters={" + params + "}");
974970

975971
if (logger.isTraceEnabled()) {
976972
List<String> values = Collections.list(request.getHeaderNames());

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: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,8 +497,7 @@ public String toString() {
497497
}
498498

499499
protected String formatViewName() {
500-
return (getBeanName() != null ?
501-
"name '" + getBeanName() + "'" : "[" + getClass().getSimpleName() + "]");
500+
return (getBeanName() != null ? "name '" + getBeanName() + "'" : "[" + getClass().getSimpleName() + "]");
502501
}
503502

504503
}

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
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

@@ -73,20 +74,12 @@ public MappingJackson2XmlView(XmlMapper xmlMapper) {
7374
super(xmlMapper, DEFAULT_CONTENT_TYPE);
7475
}
7576

76-
/**
77-
* {@inheritDoc}
78-
*/
77+
7978
@Override
8079
public void setModelKey(String modelKey) {
8180
this.modelKey = modelKey;
8281
}
8382

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

0 commit comments

Comments
 (0)