java - cvc-complex-type.2.4.a:发现以元素“位置”开头的无效内容
问题描述
我正在使用 eclipse 版本:Neon.3 Release (4.6.3) 和 Tomcat (v8.5) 进行 Java (JDK1.8) 编程。
我收到一个错误:
cvc-complex-type.2.4.a:发现以元素“位置”开头的无效内容。'{"http://java.sun.com/xml/ns/javaee":error-code, " http://java.sun.com/xml/ns/javaee":exception-type }' 之一是预期的。
我试图解决但没有
这是 web.xml 中的代码
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
version="2.5"
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_2_5.xsd">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/servlet-context.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value></param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<filter>
<filter-name>characterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>characterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<error-page>
<location>/error</location>
</error-page>
</web-app>
错误显示在location
之前的标签上/error
。
我该怎么做才能解决eclipse错误?
解决方案
改变你的web-app
元素
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
version="2.5"
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_2_5.xsd">
至
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
version="3.0"
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">
推荐阅读
- c++ - 一个线程设置成员,而另一个在其上循环 - 这是线程不安全的吗?
- swift - 通用可解码类使用什么类型
- java - 尝试使用 Dagger 将架构更改为 MVVM 时遇到问题
- python - 通过 Python 将用户输入的 PC 名称插入到 Windows CMD 关机命令中
- java - 从 Spring Boot 测试中调用的 @Caching 方法 [@Transactional 注释] 不起作用
- php - 在 Woocommerce 中为特定用户角色禁用我的帐户编辑地址
- r - 使用可变列数将长转换为宽
- python - 变量默认值的 Python 快捷方式是另一个变量值(如果它是无)
- c# - 在 C# 泛型中传递“this”在没有强制转换的情况下不起作用
- python - Keras中具有二进制分类的多标签