tomcat servlet容器的功能

发布于 2024-12-23 02:04:06 字数 147 浏览 1 评论 0原文

ServletContainer 通过将 web.xml 文件转换为 DOM 对象,从 web.xml 文件中读取用户定义的 servlet 类名。我不明白 servlet 容器如何转换它以及这个 DOM 对象(web.xml 数据)驻留在服务器的 web-app 目录中的位置?

ServletContainer reads the user defined servlet class name from web.xml file by converting web.xml file into DOM object. I don't understand how servlet container converts this and where this DOM object (web.xml data) resides inside web-app directory of server?

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

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

发布评论

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

评论(3

Java EE 规范为 Web 应用程序规定了特定的目录和打包结构(war),以便 Web 应用程序可以部署在任何 servlet 容器(Tomcat 就是其中之一)上,而无需任何修改。现在,每个 servlet 容器都可以按照自己想要的方式解压它,作为开发人员,您无需担心这一点。

现在,Tomcat 将所有已部署的应用程序放置在 \tomact-install-dir\webapps 目录中。每个 Web 应用程序都将位于其自己的文件夹中,并以 Web 应用程序名称作为文件夹名称。

The Java EE specification mandates a specific directory and packaging structure (war) for web applications so that the web app can be deployed on any servlet container (Tomcat is one of them) without any modifications. Now, each servlet container can unpack it in which ever way it wants and as a developer you no need to worry about it.

Now, Tomcat places all the deployed applications in the \tomact-install-dir\webapps directory. Each web app will be in its own folder with webapp name as thefolder name.

心的憧憬 2024-12-30 02:04:06

也许这是部署第一个 Web 应用程序时首先要查看的地方。 tomcat 部署层次结构

Perhaps this is the first place to take a look at when deploying the first web application. tomcat deployment hierarchy.

行雁书 2024-12-30 02:04:06

web.xml 应放置在 web 应用程序部署的 WEB-INF 内。一些 servlet 容器允许您在其配置目录中拥有通用或可重用的 web.xml 文件,但这不是标准的 AFAIK(大多数时候您的 web 应用程序最好是独立的)

您不需要了解 XML 文件的解析因为这一切都是由底层的 servlet 容器处理的。 (只要把它放在正确的地方即可)

web.xml should be placed inside the WEB-INF on your webapp deployment. Some servlet containers allow you to have generic or reusable web.xml files inside their configuration directories but that's not standard AFAIK (It's better for your webapp to be selfcontained most of times)

You shouldn't need to know about the parsing of the XML file since it's all handled by the servlet container under the hood. (Just place it in the right place)

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