You cannot do this from the template itself, no, but you can add a FreeMarkerViewResolver with a contentType property and set it to text / xml (or whatever).
If you need different content types for different views, you need to configure multiple ad permissions.
a source
to share