从 JSP 迁移到 Freemarker

发布于 2024-12-28 13:59:33 字数 774 浏览 3 评论 0原文

我正在开发一个 Spring 2.5 项目,其中四个不同的 Web 应用程序具有重复的 JSP(它们都是同一 Web 应用程序的派生)。我想引入 Freemarker,这样我就可以在所有 Web 应用程序中外部化和重用这些模板。然而,我想迭代地解决这个问题,因为这将是一个大项目,所以我需要 JSP 和 Freemarker 和谐相处一段时间。

我知道Spring允许链接多个ViewResolver,但是JSP的 InternalResourceViewResolver 和 Freemarker 的 FreeMarkerViewResolver 两者声明它们需要位于链中的最后。我已经尝试将它们链接起来并指定顺序优先级,但没有运气。

Freemarker 似乎在某种程度上支持 JSP,尽管我真的不知道如何在逐步迁移中使用它(http://freemarker.sourceforge.net/docs/pgui_misc_servlet.html)。

有人有什么想法吗?

I'm working on a Spring 2.5 project where four different webapps have duplicate JSPs (they were all derivations of the same webapp). I want to introduce Freemarker so I can externalize and reuse these templates across all the webapps. However, I want to approach this iteratively since it's going to be a big project, so I need JSP and Freemarker to live in harmony for awhile.

I know Spring allows chaining multiple ViewResolvers, but JSP's InternalResourceViewResolver and Freemarker's FreeMarkerViewResolver both state that they need to be last in the chain. I've tried to chain them anyways and specify an order priority, but no luck.

Freemarker seems to support JSPs to some degree, though I don't really see how I could use that in a gradual migration (http://freemarker.sourceforge.net/docs/pgui_misc_servlet.html).

Does anyone have any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初相遇 2025-01-04 13:59:33

在 Spring 2.5 中,您可能必须使用 BeanNameResolver,因为您不能有两个 URL 解析器,请参阅 此线程。在 3.0 中,这变得更加容易,您可以订购解析器。

参考

In Spring 2.5 you'll probably have to use a BeanNameResolver since you can't have two URL resolvers, see this thread. This got much easier in 3.0 where you can order resolvers.

References

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文