gpt4 book ai didi

servlets - cvc-复杂-类型.2.4.a : Invalid content was found starting with element 'init-param'

转载 作者:行者123 更新时间:2023-12-03 06:42:10 27 4
gpt4 key购买 nike

这是我的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: 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.

出了什么问题以及如何纠正此错误?

最佳答案

web.xml中元素的顺序很重要,在我遇到的所有示例中,<load-on-startup>之后 <init-param> .

<servlet>
<servlet-name>spring1</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

关于servlets - cvc-复杂-类型.2.4.a : Invalid content was found starting with element 'init-param' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5175034/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com