Grails GSP 编译?
当您编译 grails war 时,我知道 .groovy 代码被编译为字节码类文件,但我不明白容器(例如 tomcat)如何知道如何在请求时编译 GSP。集装箱懂普惠制吗? grails 安装在服务器上的事实是否与容器挂钩?
此外,当第一次使用 GSP 时,它会按需编译,并且仅编译一次。这是正确的吗?谢谢。
When you compile a grails war, I understand that the .groovy code is compiled in to bytecode class files, but I don't understand how the container (say, tomcat), knows how to compile the GSPs when they are requested. Do the containers understand GSP? Does the fact that grails is installed on the server hook into the containers?
Also, when the GSP is used for the first time, it is compiled then on demand and only once. Is this correct? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
GSP 实际上是在构建 war 时编译成类文件,而不是在运行时由 tomcat 编译 - 如果您解压 war 文件,您可以查看它的作用(查看解压后的 WEB-INF/classes 目录)
:不需要在运行时执行任何操作,因为所有内容都是预编译的。
事实并非如此;应用程序运行所需的一切都包含在 war 中,因此在容器服务器上安装 grails 没有什么区别。
The GSPs are actually compiled into class files when the war is built, and not at runtime by tomcat - if you unzip the war file, you can look at what it does (look at the unzipped WEB-INF/classes directory):
The container doesn't need to do anything at runtime, since everything's pre-compiled.
It does not; everything needed for the application to run is included in the war, so grails being installed on the container's server makes no difference.
好吧,刚刚在邮件列表中找到了这个:
从 grails 1.2 开始,gsps 在生成 war 文件时就被预编译了。
Ok, so just found this on the mailing list:
Since grails 1.2 the gsps are pre compiled when generating the war file.
GSP 与 JSP 类似,它们最终都是 servlet。
因此,当您构建 .war 文件时,您的 GSP 将被预编译为 servlet 并包含在 WEB-INF/classes .war 文件夹中。 (它们以 gsp_controlleraction_**.class 开头)
所以,不,Tomcat 不知道如何编译 GSP,但它可以执行 servlet。
文森特.
GSPs are like JSPs, they are ultimately servlets.
So, when you build a .war file, your GSP are precompiled to servlets and included in your WEB-INF/classes .war folder. (they start with gsp_controlleraction_**.class)
So, no, Tomcat does not know how to compile GSP, but it can execute the servlets.
Vincent.