cvc-complex-type.2.4.a:发现以元素“init-param”开头的无效内容;
这是我的 web.xml
xsd
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
这是 servlet 节点
<servlet>
<servlet-name>spring1</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<init-param> <!-- here is a problem -->
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-servlet.xml</param-value>
</init-param>
</servlet>
在标记行 xml 验证器上说
cvc-complex-type.2.4.a:发现以元素“init-param”开头的无效内容。 '{"http://java.sun.com/xml/ns/javaee":enabled, "http://java.sun.com/xml/ns/javaee":支持异步,"http://java.sun.com/xml/ns/ javaee":run-as, "http://java.sun.com/xml /ns/javaee":security-role-ref, "http://java. sun.com/xml/ns/javaee“:multipart-config}”是预期的。
出了什么问题以及如何纠正此错误?
This is my web.xml
xsd
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
Here is servlet node
<servlet>
<servlet-name>spring1</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<init-param> <!-- here is a problem -->
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-servlet.xml</param-value>
</init-param>
</servlet>
On the marked line xml validator says
cvc-complex-type.2.4.a: Invalid content was found starting with element 'init-param'. One of '{"http://java.sun.com/xml/ns/javaee":enabled, "http://java.sun.com/xml/ns/javaee":async-supported, "http://java.sun.com/xml/ns/javaee":run-as, "http://java.sun.com/xml/ns/javaee":security-role-ref, "http://java.sun.com/xml/ns/javaee":multipart-config}' is expected.
What is wrong and how do I correct this error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
web.xml
中元素的顺序很重要,在我遇到的所有示例中,
位于
。The order of elements in
web.xml
matters and in all examples I've come across, the<load-on-startup>
comes after<init-param>
.这很迂腐,但是
必须位于
之前,所以:It's pedantic, but
<init-param>
has to come before<load-on-startup>
, so:按照这个配置
Configure according to this