Skip to content

Commit 461b488

Browse files
committed
polishing
1 parent 6b93f41 commit 461b488

File tree

2 files changed

+20
-25
lines changed

2 files changed

+20
-25
lines changed

org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/annotation/AnnotationMethodHandlerAdapter.java

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -114,23 +114,26 @@
114114
import org.springframework.web.util.WebUtils;
115115

116116
/**
117-
* Implementation of the {@link org.springframework.web.servlet.HandlerAdapter} interface that maps handler methods
118-
* based on HTTP paths, HTTP methods and request parameters expressed through the {@link RequestMapping} annotation.
117+
* Implementation of the {@link org.springframework.web.servlet.HandlerAdapter} interface
118+
* that maps handler methods based on HTTP paths, HTTP methods and request parameters
119+
* expressed through the {@link RequestMapping} annotation.
119120
*
120-
* <p>Supports request parameter binding through the {@link RequestParam} annotation. Also supports the {@link
121-
* ModelAttribute} annotation for exposing model attribute values to the view, as well as {@link InitBinder} for binder
122-
* initialization methods and {@link SessionAttributes} for automatic session management of specific attributes.
121+
* <p>Supports request parameter binding through the {@link RequestParam} annotation.
122+
* Also supports the {@link ModelAttribute} annotation for exposing model attribute
123+
* values to the view, as well as {@link InitBinder} for binder initialization methods
124+
* and {@link SessionAttributes} for automatic session management of specific attributes.
123125
*
124-
* <p>This adapter can be customized through various bean properties. A common use case is to apply shared binder
125-
* initialization logic through a custom {@link #setWebBindingInitializer WebBindingInitializer}.
126+
* <p>This adapter can be customized through various bean properties.
127+
* A common use case is to apply shared binder initialization logic through
128+
* a custom {@link #setWebBindingInitializer WebBindingInitializer}.
126129
*
127130
* @author Juergen Hoeller
128131
* @author Arjen Poutsma
132+
* @since 2.5
129133
* @see #setPathMatcher
130134
* @see #setMethodNameResolver
131135
* @see #setWebBindingInitializer
132136
* @see #setSessionAttributeStore
133-
* @since 2.5
134137
*/
135138
public class AnnotationMethodHandlerAdapter extends WebContentGenerator
136139
implements HandlerAdapter, Ordered, BeanFactoryAware {
@@ -451,9 +454,8 @@ private ServletHandlerMethodResolver getMethodResolver(Object handler) {
451454
* @see ServletRequestDataBinder#bind(javax.servlet.ServletRequest)
452455
* @see ServletRequestDataBinder#convertIfNecessary(Object, Class, org.springframework.core.MethodParameter)
453456
*/
454-
protected ServletRequestDataBinder createBinder(
455-
HttpServletRequest request, Object target, String objectName) throws Exception {
456-
457+
protected ServletRequestDataBinder createBinder(HttpServletRequest request, Object target, String objectName)
458+
throws Exception {
457459
return new ServletRequestDataBinder(target, objectName);
458460
}
459461

@@ -466,7 +468,6 @@ protected ServletRequestDataBinder createBinder(
466468
* @throws Exception in case of errors
467469
*/
468470
protected HttpInputMessage createHttpInputMessage(HttpServletRequest servletRequest) throws Exception {
469-
470471
return new ServletServerHttpRequest(servletRequest);
471472
}
472473

@@ -479,7 +480,6 @@ protected HttpInputMessage createHttpInputMessage(HttpServletRequest servletRequ
479480
* @throws Exception in case of errors
480481
*/
481482
protected HttpOutputMessage createHttpOutputMessage(HttpServletResponse servletResponse) throws Exception {
482-
483483
return new ServletServerHttpResponse(servletResponse);
484484
}
485485

@@ -833,12 +833,11 @@ public ModelAndView getModelAndView(Method handlerMethod, Class handlerType, Obj
833833
handleResponseBody(returnValue, webRequest);
834834
return null;
835835
}
836-
if (returnValue instanceof HttpEntity) {
836+
else if (returnValue instanceof HttpEntity) {
837837
handleHttpEntityResponse((HttpEntity<?>) returnValue, webRequest);
838838
return null;
839839
}
840-
841-
if (returnValue instanceof ModelAndView) {
840+
else if (returnValue instanceof ModelAndView) {
842841
ModelAndView mav = (ModelAndView) returnValue;
843842
mav.getModelMap().mergeAttributes(implicitModel);
844843
return mav;
@@ -884,10 +883,8 @@ private void handleResponseBody(Object returnValue, ServletWebRequest webRequest
884883
if (returnValue == null) {
885884
return;
886885
}
887-
888886
HttpInputMessage inputMessage = createHttpInputMessage(webRequest);
889887
HttpOutputMessage outputMessage = createHttpOutputMessage(webRequest);
890-
891888
writeWithMessageConverters(returnValue, inputMessage, outputMessage);
892889
}
893890

@@ -898,7 +895,6 @@ private void handleHttpEntityResponse(HttpEntity<?> responseEntity, ServletWebRe
898895
}
899896
HttpInputMessage inputMessage = createHttpInputMessage(webRequest);
900897
HttpOutputMessage outputMessage = createHttpOutputMessage(webRequest);
901-
902898
HttpHeaders entityHeaders = responseEntity.getHeaders();
903899
if (!entityHeaders.isEmpty()) {
904900
outputMessage.getHeaders().putAll(entityHeaders);
@@ -1086,7 +1082,6 @@ private List<MediaType> getAcceptHeaderValue(RequestMappingInfo info) {
10861082
}
10871083
return Collections.emptyList();
10881084
}
1089-
1090-
10911085
}
1086+
10921087
}

org.springframework.web/src/main/java/org/springframework/web/bind/annotation/ResponseBody.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2009 the original author or authors.
2+
* Copyright 2002-2010 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.
@@ -23,13 +23,13 @@
2323
import java.lang.annotation.Target;
2424

2525
/**
26-
* Annotation which indicates that a method return value should be bound to the web response body. Supported for annotated
27-
* handler methods in Servlet environments.
26+
* Annotation which indicates that a method return value should be bound to the web response body.
27+
* Supported for annotated handler methods in Servlet environments.
2828
*
2929
* @author Arjen Poutsma
30+
* @since 3.0
3031
* @see RequestBody
3132
* @see org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter
32-
* @since 3.0
3333
*/
3434
@Target(ElementType.METHOD)
3535
@Retention(RetentionPolicy.RUNTIME)

0 commit comments

Comments
 (0)