簡體   English   中英

我無法運行我的 spring 啟動應用程序,因為 web.xml 文件顯示錯誤,我不知道為什么

[英]I can't run my spring boot app because web.xml file is showing an error and I don't know why

我的 web.xml 文件顯示錯誤,我不知道為什么。 當我將 go 寫入文件時,它在“<web-app”一詞的第二行顯示紅色 x。 當我 hover 出現錯誤時,它在下面顯示此消息。

在此行找到多個注釋:

  • cvc-complex-type.4:屬性“版本”必須出現在元素“web-app”上。
  • 屬性:
  • 元素中需要版本:
  • 網絡應用程序代碼:

這是我的 web.xml 文件的代碼

<?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>

在問題表中,web.xml 第二行顯示了兩個不同的錯誤。 第一類錯誤是Language Servers ,第二類錯誤是XML Problem

我移動了版本並將其放在 xmlns 文件之后,然后我重新啟動了我的項目並解決了錯誤。 這是解決問題后新代碼的樣子。

<?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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM