Spring 4:根据要求提供单独的视图布局

Spring 4: Individual view layouts depending on request

我正在使用 Spring 4 MVC 来显示我的网页。我现在想根据当前的 HttpServletRequest(例如 request.getServerName()).这意味着 https://page1.test/page.html will be mapped to the same controller as https://page2.test/page.html 和 returns 相同的内容取决于控制器逻辑,但是 page1.test 绘制为例如不同的页眉和页脚。

据我所知,Spring MVC 无法做到这一点。我现在计划使用 Apache Tiles 3 或 JSP 2.0 标签来执行此操作。有什么最佳实践吗?我该怎么做(Spring Java 配置是首选)?

你应该读一读 http://tech.finn.no/2012/07/25/the-ultimate-view-tiles-3/ 看看你能把 Tiles-3 推进多远

确实可以解决你的问题

(该博客网站刚刚从 wordpress 迁移到 github 页面,因此一些代码片段需要水平滚动,我们仍在清理这些小的格式问题,所以请原谅)