当前位置:网站首页>META-INF、WEB-INF分别是什么?
META-INF、WEB-INF分别是什么?
2022-06-12 19:13:00 【Charter1】
1. 概述
在学习spring.factories时发现自己对于META-INF和WEB-INF的作用还不甚了解,因此在这里做一个补充。
META-INF 的作用主要是对Jar包进行一个描述。其意为(meta information)签名文件夹。在打包jar时会自动的生成,当然也可以手动的配置修改。
WEB-INF 是Java的WEB应用的安全目录。所谓安全就是客户端无法访问,只有服务端可以访问的目录。
2. 详述
2.1 百度上的解释
META-INF 相当于一个信息包,目录中的文件和目录获得 Java 2 平台的认可与解释,用来配置应用程序、扩展程序、类加载器和服务 manifest.mf 文件,在用 jar 打包时自动生成。
WEB-INF是Java的WEB应用的安全目录。所谓安全就是客户端无法访问,只有服务端可以访问的目录。如果想在页面中直接访问其中的文件,必须通过web.xml文件对要访问的文件进行相应映射才能访问。
2.2 mainfest.mf文件
意为清单文件,manifest 文件中的每一行都是 key-value 对应的:属性名开头,接着是 “:” ,然后是属性值,每行最多72个字符,如果需要增加,可以在下一行续行,续行以空格开头,以空格开头的行都会被视为前一行的续行。通常有这些字段:
Manifest-Version: 1.0
Built-By: Dxy
Created-By: IntelliJ IDEA
Build-Jdk: 1.8.0_144
这些信息就是 jar 文件的描述信息:
Manifest-Version:生成的 manifest.mf 文件的版本
Built-By:文件的创建用户命名,在 IDEA 的配置文件中可以设置
Created-By:文件的生成者,一般由jar命令行工具生成,这里显示的时 idea
Bulid-Jdk:所使用的 JDK 环境
还有这些属性:
一、一般属性
1:Signature-Vresion:定义 jar 文件的签名版本
2:Class-Path:内部的类搜索路径,提供给应用程序或者类装载器
二、应用程序的相关属性
1、Main-Class:定义 jar 文件的入口类,该类必须可执行!一旦定义了该属性就可以使用
java -jar 程序名.jar 来运行该 jar 文件
2.3 和WEB-INF的区别
META-INF 存放的是 jar 包的标签信息,jar 都会有这个文件夹,war 也会有。
而 WEB-INF 是 java web 应用所特有的一个文件夹,属于 web 应用的安全目录,该目录客户端无法进行访问,只有服务端可以访问。如果想在页面中直接访问其中的文件,必须通过web.xml文件对要访问的文件进行相应映射才能访问。这样如果我们的页面中出现超链接<a>标签或者<script></script>脚本下的location.href去直接转向到WEB-INF下的某一个jsp或者html页面,那么就会引用不到,因为这样的请求方式是客户端的请求。css/js/html没有必要放在WEB-INF下。 最终这些会被原封不动的展现在客户端,所以访问安全根本就不会成为问题。
jsp放在web-inf下,原因主要有两个
远古时代的模式会把业务逻辑,数据库连接等敏感信息写在jsp里面,被用户直接访问会有安全问题。
现代模式里这个不再成为问题,不应该成为问题。
jsp是在服务器端运行的,而且通常都需要其他程序支持——比如后台处理好数据再让jsp渲染等,用户直接访问一则没有意义,二则会抛异常,这些都浪费服务器资源。
对于安全要求很严格的系统来说,不允许随便访问你的jsp文件,你可以放到web-inf下面,对于安全性要求没有那么严格的系统来说,你可以直接放到webroot下面。
3. 总结
META-INF 相比 WEB-INF在日常开发中通常用的少一些,一般其中的字段都是构建工具或者IDE自动生成的。
边栏推荐
- 【5GC】三种SSC(Session and Service Continuity)模式介绍
- chrome浏览器解决跨域问题
- In 2021, the global fire pump drive power revenue is about $381million, and it is expected to reach $489.3 million in 2028
- Report on market demand trends and future strategic planning recommendations of the global and Chinese smart financial solutions industry 2022-2028
- 攻防世界(web篇)---supersqli
- leetcodeSQL:602. Friend application II: who has the most friends
- In 2021, the global revenue of electro-optical modulator (EOM) is about USD 360.3 million, and it is expected to reach USD 704.4 million in 2028
- OpenGL shadow implementation (soft shadow)
- Vue - Advanced Vue router routing (2) (replace attribute, programming route navigation, caching route components, and exclusive hooks for routes)
- How to download Vega in China
猜你喜欢

【图像去噪】基于各向异性滤波实现图像去噪附matlab代码

VC hacon joint programming genimage3extern writeimage

5G R17标准冻结,主要讲了些啥?

The Bean Validation API is on the classpath but no implementation could be found

What is a network proxy
![leetcode:5270. Minimum path cost in Grid [simple level DP]](/img/c5/37fd1878e92f95340926e0ea75f150.png)
leetcode:5270. Minimum path cost in Grid [simple level DP]

Shell 编程正则表达式及元字符
![leetcode:5259. Calculate the total tax payable [simple simulation + see which range]](/img/f4/e6329c297dbe668e70f5e37bfc2852.png)
leetcode:5259. Calculate the total tax payable [simple simulation + see which range]

Go init initialization function

Research Report on the overall scale, major manufacturers, major regions, products and application segmentation of swimming fins in the global market in 2022
随机推荐
leetcodeSQL:578. Questions with the highest response rate
The solution of BiliBili video list name too long and incomplete display
leetcode:5289. Distribute cookies fairly [see data range + DFS pruning]
leetcode:98. Count the number of subarrays whose score is less than k [double pointers + number of calculated subsets + de duplication]
Redis (XXXII) - using redis as a distributed lock
chrome浏览器解决跨域问题
Leetcode 1049. 最后一块石头的重量 II
review. JS ppt math formula cannot be displayed
A journey of database full SQL analysis and audit system performance optimization
观察网站的页面
Cookie & Session & kaptcha驗證碼
Mysql database experiment I data definition
ThansmittableThreadLocal详解
io.seata.common.exception.FrameworkException: can not connect to services-server.
Uniapp uses the Ali Icon
Leetcodesql: count the number of students in each major
WinCC7.5 SP1调整画面尺寸以适应显示分辨率的方法
[today in history] June 12: the United States entered the era of digital television; Mozilla's original developer was born; 3com merges with American Robotics
Leetcode 1049. Weight of the last stone II
tarfile解压嵌套tar