开发者

Exposing resources from jar files in web applications (Tomcat7)

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.

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.

  • Does this feature exists in servlet api 3.0?
  • Does this feature exists in tomcat 7.0?
  • Is there another way to have jsp-files in /lib/*.jar files?


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.

When there is a clash of resource between your app and the JAR file, your apps resource will be returned. See this

Tomcat 7 supports Servlet 3 so it should support this feature

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜