Inside Controller I need to get a rendered string and do some actions with it. This string has to be rendered out of a view. Is there a simple way of doing it?
Clarification:
I have controller
@RequestMapping(value = "/")
@ResponseBody
public String renderString() {
//I NEED TO RENDER SOME CONTENT I SAVED IN A VIEW
//I DONT WANT TO RETURN THIS CONTENT BACK TO THE BROWSER
//INSTEAD I WANT TO LETS SAY SEND CONTENT VIA EMAIL
ModelAndView view = new ModelAndView("email_template", Model);
**//QUESTION IS HERE, HOW DO I GET RENDERED STRING OUT OF VIEW/MODEL?
String emailText = view.render(); ??????????**
...sendEmail(emailText);
return "Email send";
}
Hope is more clear now
As Japs told you, I’m not sure to really understand your question, but I’ll go for what I think “out of a view” means.
With Spring you can add the annotation @ResponseBody to your Controller. The String returned by the method will then be the only content of the response.
Example:
You will get “Rendered String” at screen.