在Web应用程序中公开jar文件中的资源(Tomcat7) [英] Exposing resources from jar files in web applications (Tomcat7)
问题描述
前段时间我读了一篇文章,预计将在Servlet API 3.0中出现。我记得我读过你可以在/WEB-INF/lib/somelib.jar/META-INF/web/.jsp中保存一些 .jsp文件,这些资源将暴露给上下文根Web应用程序。
Some time ago I read an article what is expected to be in Servlet API 3.0. I remember I read that you can save some .jsp files in a /WEB-INF/lib/somelib.jar/META-INF/web/.jsp and this resources will be exposed to the context root of the web application.
我刚刚安装了Tomcat7试一试,但我发现没有文档可以将一些网络资源放在jar文件中。
I have just installed Tomcat7 to give it a try, but I found no documentation that I can put some web-resources in jar-files.
- servlet api 3.0中是否存在此功能?
- tomcat 7.0中是否存在此功能?
- 在/lib/*.jar文件中有没有其他方法可以使用jsp文件?
推荐答案
servlet 3.0中有一个功能允许您将资源(图像,jsp等)打包到JAR文件中。你所做的是在你的jar文件中,你创建 META-INF / resources
并在那里转储你想要的任何内容,包括用于构建资源的目录。会发生什么是 META-INF / resources
将映射到您的Web应用程序的 docroot
。
There is a feature in servlet 3.0 that allows you to package resources (images, jsp, etc.) in a JAR file. What you do is in your jar file, you create META-INF/resources
and dump anything you want in there including directories for structuring your resources. What happens is that META-INF/resources
will be mapped to the docroot
of your web application.
当您的应用与JAR文件之间存在资源冲突时,将返回您的应用资源。请参阅此
When there is a clash of resource between your app and the JAR file, your apps resource will be returned. See this
Tomcat 7支持Servlet 3,因此它应支持此功能
Tomcat 7 supports Servlet 3 so it should support this feature
这篇关于在Web应用程序中公开jar文件中的资源(Tomcat7)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!