java调用外联服务用xml,web.xml引用外部xml文件。以及org.xml.sax.SAXException

很多时候因为各种各样的原因,需要在各种xml文件来引用外部的xml文件。

我遇到了两种,一种是普通配置的xml文件引用外部xml文件。

可以用

这是相对路径,当然,这句代码的位置需要注意。这个在beans下面,与bean平级,如果写错了,会不执行,就会导入出错,或者就是不执行也不报错。

另一种是web.xml引用外部xml文件。这个是我看大神写的。原网站如下。

http://www.blogjava.net/jiangjf/archive/2009/04/09/264685.html

我的需求和理解:

因为项目中很多东西需要放到web.xml中部署,或者,有一些相同的代码需要放到不同的web.xml中部署,所以,就用到了web.xml拆分。

根据文章介绍。

需要在文章顶部加上这个:

/p>

[

]>

这里的test 和 admin 是自定义的名称。后面两个,分别是相对路径和绝对路径。记住,是顶部,下面是我写的。

]>

xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"

xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"

id="WebApp_admin" version="3.0">

不能在里面,否则会出错的。

错误代码如下:

七月 14, 2015 10:41:53 上午 org.apache.catalina.startup.ContextConfig parseWebXml

严重: Parse error in application web.xml file at jndi:/localhost/file-server/WEB-INF/web.xml

org.xml.sax.SAXException: Scanner State 24 not Recognized

at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)

at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)

at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1537)

at org.apache.catalina.startup.ContextConfig.parseWebXml(ContextConfig.java:1883)

at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1252)

at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:878)

at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:376)

at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)

at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)

at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5322)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)

at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)

at java.util.concurrent.FutureTask.run(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

其实,就是位置不对,应该放到页面顶部。

在引用这段代码的位置,写这个就可以了

&tulogin; & + 你自己定义的名称 + ;还有一个问题。

项目部署的时候,会自动执行web.xml。所以,如果一个项目中,引用了另外项目的xml,这个,我不知道怎么解决这个问题。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值