cvc-complex-type.2.4.d:(...)No child element is expected at this point.的报错原因和解决方法

先看源代码:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:web="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd "
version="2.4">
<display-name>Travel</display-name>
<!-- tta 4.0 -->
<!-- 系统控制参数 -->
<!-- 使用ContextLoaderListener配置时,需要告诉它Spring配置文件的位置 -->
<!-- 如果没有指定,上下文载入器会在/WEB-INF/applicationContext.xml中找Spring配置文件 -->
<!-- 我们可以通过在Servlet上下文中设置contextConfigLocation参数,来为上下文载入器指定一个或多个Spring配置文件 -->
<!-- 注意:contextConfigLocation参数是一个用逗号分隔的路径列表,其路径是相对于Web系统的根路径的 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/travelservice-*.xml</param-value>
</context-param>
<!-- <context-param>Log4j配置 在同一容器中部署多个应用不能使用默认的webAppRootKey,必须指定唯一KEY,以免冲突 
<param-name>webAppRootKey</param-name> <param-value>trustWeb.root</param-value> 
在log4j.properties中设置日志路径log4j.appender.file.File=${trustWeb.root}/WEB-INF/itservice.log 
</context-param> -->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/classes/log4j.properties</param-value>
</context-param>

<!-- 配置上下文载入器 -->
<!-- 上下文载入器载入除DispatcherServlet载入的配置文件之外的其它上下文配置文件 -->
<!-- 最常用的上下文载入器是一个Servlet监听器,其名称为ContextLoaderListener -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>

<!-- SpringMVC的前端控制器 -->
<!-- 当DispatcherServlet载入后,它将从一个XML文件中载入Spring的应用上下文,该XML文件的名字取决于<servlet-name> -->
<!-- 这里DispatcherServlet将试图从一个叫做springmvc-servlet.xml的文件中载入应用上下文,其默认位于WEB-INF目录下 -->
<!-- 所以ContextLoaderListener参数值也可写成<param-value>classpath:applicationContext-*.xml</param-value> -->
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/travelservice-*.xml</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>*.jho</url-pattern>
</servlet-mapping>
</web-app>
这篇博文描述的问题就是我所要说的,红色字体处报错,主要看problem报错详情,

翻译后半部分 No child element is expected at this point.意思是:此时不希望有子元素,那就意思说:一个标签里面别多写,其实可以参考其他标签写法,多少应该可以看出端倪,那么就改为包含部分别出现重复类标签就行,具体这样:

	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>
	<listener>
		<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
	</listener>

ok,解决!!!

猜你喜欢

转载自blog.csdn.net/vayne_xiao/article/details/54340953