ATG Dynamo 5 - 如何将所有 URI 重定向到同一页面
我为什么要这么说:
我正在开发一个 1998 年风格的网站。它分布在框架中。许多在使用模板语言之前从未使用过 RTFM 的人都接触过它,并且大多数 jhtml 文件读起来更像是带有少量逻辑的 servlet 列表,而不是带有少量模板标签的 HTML 模板,用于动态重复元素和插入的动态值。
这是一个非常不灵活的紧密耦合的意大利面条怪物应用程序,尤其是从前端开发人员的角度来看。
我非常喜欢 Django 解决问题的方法,并且想尝试构建一些类似 URI 配置文件的东西,该文件基本上将 regEx URI 模式映射到控制器(传递捕获的参数是真正有用的地方),然后加载建立模板文件并插入业务逻辑以呈现适当的页面。
我是 Java 新手,但我假设我会编写 servlet 来处理这个问题。
Why I would want to follows:
I'm working on a site that is pretty 1998. It's distributed into frames. A lot of hands that never RTFM'd before using the templating language have touched it and most of the jhtml files read more like lists of servlets with a dash of logic than HTML templates with a dash of templating tags for dynamic repetition of elements and insertions of dynamic values.
It's a pretty inflexible tightly coupled spaghetti monster of an app, especially from a front end dev's perspective.
I'm very fond of Django's approach to the problem and would like to take a crack at building something like it's URI config file which basically maps regEx URI patterns to controllers (passing in captured parameters is where that gets really useful) which in turn load up template files and plugs in the business logic to render the appropriate page.
I'm new to Java but I'm assuming I'd be writing servlets to handle this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我们在 ATG 中做了一些类似的事情。我们将一个 servlet 放入执行 request.getServletPath() 的管道中,然后根据我们的规则检查该路径。如果匹配,它将使用请求调度程序将请求发送到正确的 JSP。除了位于 ATG 请求管道中之外,这一切都是通过标准 J2EE API 完成的。
We've done something slightly like this in ATG. We put a servlet in the pipeline that does request.getServletPath(), then checks that path against our rules. If it matches, it uses a request dispatcher to send the request to the right JSP. It's all done with the standard J2EE API, apart from the fact that it's in the ATG request pipeline.
既然您提到了 ATG 5 和 JHTML,我认为这是非常老式的 ATG。另外,我猜你对 ATG 还很陌生。
您可能想首先探索 JHTML 使用 Droplet 来包含其他页面(而不是- 仅在 JHTML 中的东西,不在 ATG 的 JSP 实现中),为现有页面组合一个粗略的模板系统。
其次,您可能想查看 URI 映射的 servlet 和 servlet 管道。
Since you mention ATG 5 and JHTML, I assume this is very old-school ATG. Also, you I assume you are VERY new to ATG.
You may want to start by exploring JHTML's use of droplets to include other pages (<droplet src="..."> instead of <droplet bean="..."> - something that is only in JHTML, not in ATG's JSP implementation), to put together a crude templating system for existing pages.
Secondly you may want to look at the URI-mapped servlets and the servlet pipeline.