XSD 文件本地加载

  在 JavaEE 工程中,会使用 XML 配置文件,XML 配置文件在解析时会加载 XSD 文件,但是 XSD 文件通常是在国外网站上的,经常会出现因为网络等原因造成的 XSD 文件加载不进来的问题,这时可以采用本地加载的形式。

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0">
  <display-name>JavaWeb1</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  第一步:下载 xsd 文件

  打开http://xmlns.jcp.org/xml/ns/javaee网站,从中找到需要下载的 xsd 文件,我这里需要下载的是 web-app_4_0.xsd 文件。
  将下载后的文件找一个位置放好,推荐将 xsd 文件专门放到一起。

  第二步:配置 Eclipse

  Window → Preferences → XML → XML Catalog → 选中 User Specified Entries → Add → 填好信息 → OK → Apply And Close
在这里插入图片描述

  配置完成之后,使用方法还是和以前一样,不需要修改 web.xml 文件,但是加载的时候优先从本地加载。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值