Reputation: 85
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?
Upvotes: 1
Views: 1206
Reputation: 38300
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.Upvotes: 1