I am trying to develop a grails application that returns kml (to be viewed in Google Earth) using the controller code snippet below.
render(contentType: "application/vnd.google-earth.kml+xml",
view:"kml",
model:[feeds: feeds, feedColors: feedColors]);
This works great...but Google Earth does not open the response until it is first saved to disk and renamed with a '.kml' extension. This is very annoying and will greatly limit the use of my web application.
开发者_开发知识库How do I add the .kml extension to the response name returned from grails render method?
I think this will work:
response.setHeader("Content-disposition", "attachment; filename=${filename}.kml");
render(contentType: "application/vnd.google-earth.kml+xml",
view:"kml",
model:[feeds: feeds, feedColors: feedColors]);
精彩评论