java - Default Servlet 是(事实上的)标准吗?

标签 java servlets

this question相关, 提供静态内容的默认 servlet 的想法是跨 servlet 容器的标准(即使是事实上的标准),还是它的使用限制部署到 Tomcat/Jetty?

例如,1展示了这种获取默认调度程序的方法:

 final RequestDispatcher rd = getServletContext().getNamedDispatcher("default");

通过快速搜索,这似乎也适用于 Jetty。这种技术在多大程度上适用于获取默认的 servlet?对于具有默认 servlet 的 servlet 容器,它是否始终是静态内容 servlet?

最佳答案

它不是标准,但没有它,应用服务器就无法提供静态内容。这很重要。

[编辑] 我看到您以更清晰的方式编辑和阐述了您的问题:

For example, [1] shows this method for getting the default dispatcher:

final RequestDispatcher rd = getServletContext().getNamedDispatcher("default");

From a quick search it seems that this would also work on Jetty. How broadly will this technique work for obtaining a default servlet? For the servlet containers that have a default servlet, is it always a static content servlet?

在那种情况下,它可能是事实上的标准,但我不会太依赖它,并且肯定不会针对实现的特定细节甚至是事实上的标准编写代码。问问自己:将请求分派(dispatch)给 defaultservlet 的意义/值(value)是什么?没错,什么都没有。

关于java - Default Servlet 是(事实上的)标准吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1661082/

相关文章:

java - 如何使用 JSOUP 或 Coldfusion 从 URL 中删除查询字符串和哈希值?

java - 访问动态壁纸服务类中的子方法

java - 这个错误: Missing stack map in ....是什么?

java - java输出的解释(hibernate)

Java-文件上传问题

java - eclipse 提示我的 JPA NamedQuery

java - UnsupportedClassVersionError 异常阻止 Tomcat 启动

java - Spring MVC HTTP 错误 500 : Servlet. init() 的 servlet 通知抛出异常

java - Servlet.service() 抛出 NullPointerException

eclipse - 非法参数异常 : The servlets named [HelloWorlds] and [Hello] are both mapped to the url-pattern [/sHelloWorld] which is not permitted