从 Web 应用程序 (Tomcat7) 中的 jar 文件公开资源 [英] Exposing resources from jar files in web applications (Tomcat7)

查看:23
本文介绍了从 Web 应用程序 (Tomcat7) 中的 jar 文件公开资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

前段时间我读了一篇文章,预计 Servlet API 3.0 中的内容.我记得我读过你可以将一些 .jsp 文件保存在/WEB-INF/lib/somelib.jar/META-INF/web/.jsp 中,这些资源将暴露给上下文根网络应用程序.

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 应用程序 (Tomcat7) 中的 jar 文件公开资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆