에러

[에러] cvc-elt.1.a: Cannot find the declaration of element 'web-app'. 에러 해결법 (web.xml)

수키 💻 2022. 3. 14. 12:43
반응형

[에러] cvc-elt.1.a: Cannot find the declaration of element 'web-app'. 

에러해결 (web.xml)

 

 

✔ 현상

web.xml의 web-app부분에 빨간색 X표시가 떴다

 


 해결방법

구글링해보니까 해결 방법이 여러가지가 있던데 나는 변경된 서블릿 버전 문제였다. 

(나는 4번방법으로 해결함)

 

 

1. 해당 문서 아무 위치에나 커서를 놓고 아무 조작해보기

https://change-words.tistory.com/entry/webxml-%ED%8C%8C%EC%9D%BC-web-app%EC%97%90-%EC%97%90%EB%9F%AC-%EB%B9%A8%EA%B0%84%EC%A4%84-%ED%95%B4%EA%B2%B0%EB%B2%95

 

web.xml 파일 web-app에 에러 | 빨간줄 해결법

다이나믹 웹 프로젝트에서 WEB-INF 폴더 안에 있는 web.xml 파일을 열면 web-app 부분에 빨간줄로 에러 표시가 나타나곤 합니다. 해결법은 싱겁게도, 문서 위치에나 커서를 놓고 아무 조작이나하는 것

change-words.tistory.com

 

2. web-app 태그의  sci:schemaLocation에있는 java를 Java 대문자로 변경

https://heekng.tistory.com/95

 

web.xml cvc-id.3 에러 해결

web.xml에서 cvc-id.3: Afield of identity constraint 'web.app-servlet-name-uniqueness' matched element 'web-app', but this element does not have a simple type. 위 에러 발생시 web-app 태그의 sci:sche..

heekng.tistory.com

 

3. web.xml 의 java.sun.com 에서 java를 대문자로 변경 (JAVA.sun.com)

https://hojin880214.tistory.com/56

 

20210319 - web.xml 에러

www.programmersought.com/article/40922001615/ web.xml file error: Referenced file contains errors, cvc-id.3: A field of identity constraint - Programmer Sought web.xml file error: Referenced file co..

hojin880214.tistory.com

 

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://kim22036.tistory.com/entry/%EC%84%9C%EB%B2%84-jsp-servlet-%EB%B2%84%EC%A0%84-%ED%99%95%EC%9D%B8%ED%95%98%EB%8A%94-%EB%B0%A9%EB%B2%95

 

서버, jsp, servlet 버전 확인하는 방법

 - URL : http://www.munsam.info/xe/jsp_lec/1589007  위 URL 참고 <요약> * 이클립스 jsp 페이지에서  - 서버 : <%=application.getServerInfo() %>  - 서블릿 : <%= application.getMajorVersion() %>.<%=..

kim22036.tistory.com

https://heekng.tistory.com/107

 

[Spring] web.xml cvc-elt.1.a: Cannot find the declaration of element 'web-app'

cvc-elt.1.a: Cannot find the declaration of element 'web-app' 오류 해결방법 스프링에서 servlet 버전을 3.1로 올린 후 web.xml에서 위와 같은 오류가 발생 xsi:schemaLocation의 버전부분만 3_1로 변경하면..

heekng.tistory.com

 

반응형