Java – which return type is used in the spring MVC of the @ requestmapping method?

I know that in spring, I can return the @ requestmapping method of MVC in @ controller

>String > model > modelandview

I don't understand the difference between these behaviors Can you explain

Solution

In spring 3.2 There are more in X, just those 3 See the spring website documentation Latests Spring(4.2.x) documentation.

The following are the supported return types:

>Modelandview object, where the model implicitly enriches the results of the command object and @ modelattribute annotation referencing the data accessor method. > The model object and view name are implicitly determined by requesttoviewnametranslator, which implicitly enriches the model of the command object and references the results of the data accessor method with the @ modeldistribution annotation. > The view name of the map object used to expose the model is implicitly determined by requesttoviewnametranslator, which implicitly enriches the model of the command object and the results of the data accessor method referenced by the @ modelattribute annotation. > A view object whose model is implicitly determined by referencing the data accessor method through the command object and @ modelattribute annotation Handler methods can also enrich the model programmatically by declaring a model parameter (see above). > A string value interpreted as a logical view name, where the model is implicitly determined by the command object and the @ modelattribute annotation reference data accessor method Handler methods can also enrich the model programmatically by declaring a model parameter (see above). > Void if the method processes the response itself (declare a parameter of type servletresponse / httpservletresponse for this purpose by directly writing the response content), or the view name should be implicitly determined by requesttoviewnametranslator (do not declare the response parameter handler method signature). > If the method is annotated with @ ResponseBody, the return type will be written to the HTTP body of the response The return value will be converted to the declared method parameter type using httpmessageconverters See the section "mapping response body using @ ResponseBody Annotation". > An httpentity * * or * * responseentity object to provide access to the HTTP header and content of the servlet response Entities will use httpmessageconverters to convert to response streams See the section "using httpentity". > When an application wants to generate a return value asynchronously in a thread managed by spring MVC, it can return callable. > When the application wants to generate a return value from the thread of its choice, it can return deferredresult. > Any other return type the first mock exam is considered to be a single model property to expose to the view, using the attribute name specified at the method level (or the default attribute name based on the return class class name) through @modelattribute. The model implicitly enriches the results of data accessor methods referenced by command objects and @ modelattribute annotations

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>