Reputation: 7317
I created a custom view that uses Json.Simple to serialize the model and write the JSON to the response directly.
For some requests, I need to send back a static JSON message, so I am wondering can I reuse a View instance I created earlier (with the message already set)?
My View class is thread-safe.
Upvotes: 1
Views: 233
Reputation: 388406
I do not see any problem in reusing an already created view since the render
method gets current response
object.
Upvotes: 0
Reputation: 403551
Sure. As long as you make sure it's thread-safe, as you say, there's no reason that your controller can't return the same View
object multiple times. Unorthodox, but valid.
Upvotes: 3