반응형
[에러] cvc-elt.1.a: Cannot find the declaration of element 'web-app'.
에러해결 (web.xml)
✔ 현상
web.xml의 web-app부분에 빨간색 X표시가 떴다
✔ 해결방법
구글링해보니까 해결 방법이 여러가지가 있던데 나는 변경된 서블릿 버전 문제였다.
(나는 4번방법으로 해결함)
1. 해당 문서 아무 위치에나 커서를 놓고 아무 조작해보기
2. web-app 태그의 sci:schemaLocation에있는 java를 Java 대문자로 변경
3. web.xml 의 java.sun.com 에서 java를 대문자로 변경 (JAVA.sun.com)
https://hojin880214.tistory.com/56
4. Servlet버전별로 맞는 web.xml 스키마 헤더로 변경
4-1. 버전 확인 (jsp에서)
<%= application.getMajorVersion() %>.<%= application.getMinorVersion() %>
4-2. Servlet버전별로 맞는 web.xml 스키마 헤더로 변경
* servlet 4.0
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
</web-app>
* servlet 3.1
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
</web-app>
* servlet 3.0
<?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">
</web-app>
* servlet 2.5
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="servlet-2_5" version="2.5"
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_2_5.xsd">
</web-app>
* servlet 2.4
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="servlet-2_4" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
</web-app>
* servlet 2.3
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
</web-app>
* servlet 2.2
<?xml version="1.0" encoding="UTF-8"?>
<!!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
</web-app>
Reference
https://heekng.tistory.com/107
반응형