0

My web.xml file is showing an error and I don't know why. When I go to the file it showing red x on line two on the word "<web-app". When I hover on the error it showing this message below.

Multiple annotations found at this line:

  • cvc-complex-type.4: Attribute 'version' must appear on element 'web- app'.
  • Attribute:
  • version is required in element:
  • web-app Code:

Here's the code for my web.xml file

<?xml version="1.0" encoding="UTF-8"?>
<web-app 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" id="WebApp_ID">
    <display-name>springboot-server</display-name>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>
</web-app>

In the problem tabe is showing two different errors is in the web.xml line two. The first type of error is Language Servers and the second type error is XML Problem.

  • I think you need to specify the web-app version within the beginning tag. ` – arooney88 Aug 16 '22 at 21:01
  • @arooney88 can you please specify how the web-app version within the beginning tage need to look? Here's how the beginning of the web-app code look base on your suggestion. `` I did add the version and still showing error after I save it. – Jean Baptiste Asong Aug 18 '22 at 15:15

1 Answers1

0

I moved the version and put it after the xmlns file and I restart my project and the error was solved. Here's how the new code looks like with the issue solved.

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" version="2.4" 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" id="WebApp_ID">
    <display-name>springboot-server</display-name>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>
</web-app>