关于web.xml中<web-app>报错解决方案

本文介绍了在Web应用部署过程中遇到的一个配置文件错误,并提供了两种解决方案:一是调整配置文件内的元素顺序;二是移除DTD验证代码。这两种方法都能有效解决因配置文件不符合DTD规范而产生的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

严重: Parse Error at line 31 column 11: The content of element type "web-app" must match "(icon?,display-name?,description?,distributable?,context-param*,filter*,filter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mapping*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,security-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-local-ref*)"

查阅网上资料大部分给出的意见是,应严格按照icon?,display-name?,description?,distributable等等这种顺序添加节点。 

按照此法仔细对照修改后,错误终于消失了。


还有一种说法是把  <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">这一段校验代码删掉,问题就解决了。原因是:自己添加的部分代码符合xml文档规范,但不符合web-app_2_3.dtd所定义的规范。不过还没遇到过此种情况,留着备用。

<?xml version="1.0" encoding="UTF-8"?> <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 file:///D:/JAVA/web-app_4_0.xsd" version="4.0"> <display-name>Real Estate Management System</display-name> <!-- Character Encoding Filter --> <filter> <filter-name>CharacterEncodingFilter</filter-name> <filter-class>com.realestate.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>CharacterEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- Authentication Filter --> <filter> <filter-name>AuthenticationFilter</filter-name> <filter-class>com.realestate.filter.AuthenticationFilter</filter-class> </filter> <filter-mapping> <filter-name>AuthenticationFilter</filter-name> <url-pattern>/pages/*</url-pattern> </filter-mapping> <!-- Session Listener --> <listener> <listener-class>com.realestate.listener.SessionListener</listener-class> </listener> <!-- Welcome File List --> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <!-- Session Configuration --> <session-config> <session-timeout>30</session-timeout> </session-config> <!-- Error Pages --> <error-page> <error-code>404</error-code> <location>/pages/error/404.jsp</location> </error-page> <error-page> <error-code>500</error-code> <location>/pages/error/500.jsp</location> </error-page> </web-app> Attribute version is not allowed here Element display-name is not allowed here
06-12
Maven项目我引入我自己打包好的jar和pom文件,但是进入到这个项目里面去看里面定义的项目版本号是爆红是什么问题? <parent> <groupId>com.hgsoft</groupId> <artifactId>xk-issue-service</artifactId> <version>1.0.0</version> </parent> <artifactId>xk-issue-service-api</artifactId> <properties> <start-class>com.hgsoft.XKIssueServiceApplication</start-class> </properties> <dependencies> <!-- <dependency> <groupId>com.hgsoft.ecip</groupId> <artifactId>ecip-open-api</artifactId> <version>${ecip.version}</version> </dependency> <dependency> <groupId>com.hgsoft.ecip</groupId> <artifactId>ecip-auto-poi</artifactId> <version>${ecip.version}</version> </dependency> --> <!-- <dependency> <groupId>com.hgsoft.ecip</groupId> <artifactId>ecip-api-admin</artifactId> <version>${ecip.version}</version> </dependency> --> <dependency> <groupId>com.hgsoft.ecip</groupId> <artifactId>ecip-test</artifactId> <version>${ecip.version}</version> </dependency> <!-- <dependency> --> <!-- <groupId>com.hgsoft.ecip</groupId> --> <!-- <artifactId>ecip-test</artifactId> --> <!-- <version>${project.version}</version> --> <!-- </dependency> --> <!-- xxl-job-core --> <!-- <dependency> <groupId>com.hgsoft.ecip</groupId> <artifactId>ecip-rest</artifactId> <version>${ecip.version}</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-to-slf4j</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>5.2.9.RELEASE</version> </dependency> <dependency> <groupId>com.hgsoft</groupId> <artifactId>xk-issue-service-business</artifactId> <version>1.0.0</version> </dependency> </dependencies> ecip-test进去 <parent> <artifactId>ecip-web-parent</artifactId> <groupId>com.hgsoft.ecip</groupId> <version>1.9.2.20230706-xkfx-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>ecip-test</artifactId> <dependencies> <dependency> <groupId>com.hgsoft.ecip</groupId> <artifactId>ecip-bpm-api-client-starter</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>com.hgsoft.ecip</groupId> <artifactId>ecip-web</artifactId> <version>${project.version}</version> <scope>provided</scope> </dependency> </dependencies> ${project.version}这个地方是报错,Dependency com.hgsoft.ecip:ecip-bpm-api-client-starter:${project.version} not found
最新发布
06-13
<configuration> <connectionStrings> <add name="DB-NetShopsConnectionString" connectionString="Data Source=.\MSSQLSERVER2012;Initial Catalog=DB-NetShops;User ID=sa;Password=your_password;Integrated Security=False" providerName="System.Data.SqlClient" /> </connectionStrings> <system.web> <compilation debug="true" targetFramework="4.7.2" /> <httpRuntime targetFramework="4.7.2" maxRequestLength="20480" executionTimeout="300" requestValidationMode="4.7.2" /> <!-- 修正 sessionState 属性名 --> <sessionState mode="InProc" timeout="20" httpOnlyCookies="true" /> <!-- 正确:httpOnlyCookies(无多余s) --> <authentication mode="Forms"> <!-- 修正 forms 属性名 --> <forms loginUrl="~/WebForm1.aspx" defaultUrl="~/WebForm2.aspx" timeout="20" httpOnlyCookies="true" /> <!-- 正确:httpOnlyCookies(无多余s) --> </authentication> <globalization culture="zh-CN" uiCulture="zh-CN" requestEncoding="utf-8" responseEncoding="utf-8" /> <customErrors mode="RemoteOnly" defaultRedirect="~/Error.aspx"> <error statusCode="404" redirect="~/404.aspx" /> <error statusCode="500" redirect="~/500.aspx" /> </customErrors> </system.web> <system.webServer> <httpProtocol> <customHeaders> <add name="X-Content-Type-Options" value="nosniff" /> <add name="X-Frame-Options" value="SAMEORIGIN" /> <add name="X-Xss-Protection" value="1; mode=block" /> </customHeaders> </httpProtocol> <staticContent> <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" /> </staticContent> <security> <requestFiltering> <requestLimits maxAllowedContentLength="20971520" /> </requestFiltering> </security> </system.webServer> <system.codedom> <compilers> <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" /> </compilers> </system.codedom> </configuration> 报错不允许使用httpOnlyCookies特性
06-10
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值