Rendering Views as String with Spring MVC and Apache Tiles
Posted
by
lynxforest
on Stack Overflow
See other posts from Stack Overflow
or by lynxforest
Published on 2011-01-06T19:04:10Z
Indexed on
2011/01/13
23:53 UTC
Read the original article
Hit count: 199
I am trying to reuse some of my tiles in a controller which is returning a json response to the client. I would like to return a json response similar to the following format:
{
'success': <true or false>,
'response': <the contents of an apache tile>
}
In my controller I would like to perform logic similar to this pseudocode:
boolean valid = validator.validate(modelObj)
String response = ""
if(valid){
response = successView.render() // im looking for a way to actually accomplish
// this, where the successView is the apache tiles view.
// I would also need to pass a model map to the view somehow.
}else{
response = errorView.render()
}
writeJsonResponse(httpResponse, /* a Map whose json representation looks like the one I described above. */)
© Stack Overflow or respective owner