jsp页面是如何执行的,其原理是什么?

发布于 2024-08-26 09:51:25 字数 243 浏览 13 评论 0原文

我正在阅读构建 Web 应用程序骨架的步骤:

http://maestric.com /doc/java/spring/setup#web_app_sculpture

感觉和PHP等其他语言有很大的不同。

它是如何执行的?

I'm reading the steps to build a web app skeleton:

http://maestric.com/doc/java/spring/setup#web_app_skeleton

And feel it's greatly different from other languages like PHP.

How is it executed?

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

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

发布评论

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

评论(1

却一份温柔 2024-09-02 09:51:25

web.xml 是部署描述符。它实际上并没有以某种方式工作,服务器(servlet 容器)读取此文件以了解应用程序的需求是什么(要创建哪些过滤器、servlet、配置参数等)。

考虑一下 CGI。在 CGI 中,您有执行并输出 HTML 的代码。 Java 中的等效项是 Servlet。您有包含 HTML 的 Java 代码。

JSP 是一个彻底翻转的 Servlet。您有包含 Java 代码的 HTML。当“执行”JSP 时,服务器实际上会将其彻底翻转并将其转换为 Servlet。

然后执行 servlet,而不是 JSP。

PS这当然是一个简单的描述,幕后还发生了很多事情。

web.xml is a deployment descriptor. It does not actually work in a way, the server (servlet container) reads this file to know what your application's needs are (what filters to create, servlets, configuration params etc).

Consider CGI for a second. In a CGI you have code that is executed and outputs HTML. The equivalent of this in Java is a Servlet. You have Java code that includes HTML.

The JSP is a Servlet turned inside out. You have HTML that includes Java code. When "executing" a JSP, the server will in fact turn it inside out and transform it into a Servlet.

The servlet is then executed, not the JSP.

P.S. this is off course a simplistic description, a lot more is going on behind the scenes.

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