What is the difference between render and model in Grails?
Example render(text : map.toJson(list),contentType:"text/json") [text : map.toJson(list)]
What is the difference between render and model in Grails?
Example render(text : map.toJson(list),contentType:"text/json") [text : map.toJson(list)]
I think you must go through the Grails Documentation first for a more detailed understanding. However, in any RAD (Rapid Application Development) Framework, these concepts are identical.
render in any sense is used to render something as a response. This is decided by the key words you use. For example in your question, you have asked the action in your controller to send a response to a request as a JSON string.In your question, the map is the model.
Model on the other hand is what you are trying to render. To put in simply, model is an object. This object could contain a single object like a Domain entity or it could contain a lot more. In grails, you would generally use model as a keyword when your trying to render a view or a template. The model is passed on to the template and you can have access to the objects in the model directly.