使用Aspect将响应标题添加到所有控制器

我希望我所有的Spring MVC控制器都包含一些常见的响应头文件。

我可以使用以下(Kotlin)做到这一点:

@ModelAttribute open fun responseHeaders(response: HttpServletResponse) { //identify the node that serviced the call response.setHeader("host-name", InetAddress.getLocalHost().hostName); //etc } 

。 。 因为它适用于所有,我可以使用基类。 但是,有没有建议的方式来使用一个方面?