- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我创建了一个抽象基类Page
,它说明了如何构建动态网页。我正在尝试想出一种基于作为 HttpServletRequest
传入的 GET
请求生成 Page
的好方法。例如...
public class RootServlet extends HttpServlet {
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) {
Page page = Page.generatePage(request);
// do stuff with page and write back response
}
}
在 generatePage()
方法中,我必须以某种方式找出正在请求的页面,构建正确的页面,然后返回它的实例。但我不知道如何做好这件事...例如,我需要处理传入的这些类型的 URL:
http://example.com/ : build the default home page
http://example.com/ab123 : build the page corresponding to the given token "ab123"
http://example.com/about/ : build the "about" page
http://help.example.com/ : build the "help" page
这些“页面”中的每一个都扩展了抽象基类Page
,因此它们知道如何构建自己,但我不确定如何确定AboutPage
需要要构建的,或 HelpPage
,而不是默认的 HomePage
。
我正在使用Apache Velocity作为模板引擎,因此这些 Page
对象实际上只包含生成该页面所需的重要信息,例如要使用哪些样式和脚本,以及要在页面上显示的相关内容。
我认为有比查看 URL 末尾并查看“about”是否是构建 AboutPage
的子字符串更好的方法。有什么建议么?
最佳答案
有许多现成的工具框架可以为您完成此任务。至少我建议使用 Spring MVC,它将与速度一起工作。
关于java - 给定 HttpServletRequest 的网页服务的良好模式是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10744343/
嗨,我正在考虑开发一种文件传输程序,想知道我是否想要尽可能好的加密,我应该使用什么? 我会用 C# 开发它,所以我可以访问 .net 库 :P在我的 usb 上有一个证书来访问服务器是没有问题的,如果
我创建的这个计算两个数组的交集是线性的方法的复杂度(在良好、平均、最差的情况下)? O(n) public void getInt(int[] a,int[] b){ int i=0; int
我已经能够使用 RTCPeerConnection.getStats() API 获得 WebRTC 音频调用的各种统计信息(抖动、RTT、丢包等)。 我需要将整体通话质量评为优秀、良好、一般或差。
基本问题: 如果我正在讲述/修改数据,我应该通过索引硬编码索引访问文件的元素,即 targetFile.getElement(5);通过硬编码标识符(内部翻译成索引),即 target.getElem
在 Linux 上,我想知道要调用什么“C”API 来获取每个 CPU 的统计信息。 我知道并且可以从我的应用程序中读取 /proc/loadavg,但这是系统范围的负载平均值,而不是每个 CPU 的
在客户端浏览器中使用 fetch api,GET 或 POST 没有问题,但 fetch 和 DELETE 有问题。它似乎将 DELETE 请求方法更改为 OPTIONS。 大多数研究表明是一个cor
我是一名优秀的程序员,十分优秀!