I am reading spring framework reference. When i read here . I found that spring mvc supports returning void
types.And then i read some examples of using void
.But these examples do not make me to understand when time to use void
.Is there a better example of how to use it?
From the referenced document:
"... if the method handles the response itself (by writing the response content directly, declaring an argument of type ServletResponse / HttpServletResponse for that purpose) or if the view name is supposed to be implicitly determined through a RequestToViewNameTranslator (not declaring a response argument in the handler method signature)"
There are two conditions listed.
void
tells spring "I got this" and it does nothing with the response. RequestToViewNameTranslator
. In this situation, spring knows the view to return based on the request, so no return value is required.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.