笔者最近学习一些spring mvc,在复制别人代码的时候报这个错。报错来源web.xml,原因是不符合xsd对xml的约束

源文件

<?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/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0"> <servlet>
<!--名称 -->
<servlet-name>springmvc</servlet-name>
<!-- Servlet类 -->
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- 启动顺序,数字越小,启动越早 -->
<load-on-startup>1</load-on-startup>
<init-param>
<!--SpringMVC配置参数文件的位置 -->
<param-name>contextConfigLocation</param-name>
<!--默认名称为ServletName-servlet.xml -->
<param-value>classpath*:springmvc-servlet.xml</param-value>
</init-param>
</servlet> <!--所有请求都会被springmvc拦截 -->
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping> </web-app>

解决方法:

调整<load-on-startup>节点的顺序,放到</servlet>之前,修改后的web.xml如下

<?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/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0"> <servlet>
<!--名称 -->
<servlet-name>springmvc</servlet-name>
<!-- Servlet类 -->
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<!--SpringMVC配置参数文件的位置 -->
<param-name>contextConfigLocation</param-name>
<!--默认名称为ServletName-servlet.xml -->
<param-value>classpath*:springmvc-servlet.xml</param-value>
</init-param>
<!-- 启动顺序,数字越小,启动越早 -->
<load-on-startup>1</load-on-startup>
</servlet> <!--所有请求都会被springmvc拦截 -->
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping> </web-app>

cvc-complex-type.2.4.a: Invalid content was found starting with element 'init-param'.的更多相关文章

  1. Type cvc-complex-type.2.4.a: Invalid content was found starting with element 'build'.错误的解决方法

    项目突然间爆出了这样的问题: Description Resource Path Location Typecvc-complex-type.2.4.a: Invalid content was fo ...

  2. cvc-complex-type.2.4.a: Invalid content was found starting with element

    在写xml的时候又一次总是报cvc-complex-type.2.4.a: Invalid content was found starting with element 错误,还出现小红叉,在网上找 ...

  3. cvc-complex-type.2.4.a: Invalid content was found starting with element ‘init-param’(转)

    在写xml的时候又一次总是报cvc-complex-type.2.4.a: Invalid content was found starting with element 错误,还出现小红叉,在网上找 ...

  4. 【解决方案】cvc-complex-type.2.4.a: Invalid content was found starting with element 'init-param'. One of '{"http://java.sun.com/xml/ns/javaee":run-as, "http://java.sun.com/xml/ns/javaee":security-role-r

    [JAVA错误] cvc-complex-type.2.4.a: Invalid content was found starting with element 'init-param'. One o ...

  5. web.xml文件报错:cvc-complex-type.2.4.a: Invalid content was found starting with element 'init-param'.

    <?xml version="1.0" encoding="UTF-8"?> <web-app version="3.0" ...

  6. Invalid content was found starting with element 'taglib'”

    今天在使用struts-menu制作菜单,在web.xml中写入 <taglib>      <taglib-uri>/WEB-INF/struts-menu.tld</ ...

  7. 异常:cvc-complex-type.2.4.a: Invalid content was found starting with element

    web.xml 出现cvc-complex-type.2.4.a: Invalid content was found starting with element <web-app xmlns= ...

  8. shiro中async-supported报错 cvc-complex-type.2.4.a: Invalid content was found starting with element 'async-supported'. One of '{"http://java.sun.com/xml/ns/ javaee":init-param}' is expected.

    最近都在研究shiro这个框架,今天实施了一下,就报了如下错误: cvc-complex-type.2.4.a: Invalid content was found starting with ele ...

  9. cvc-complex-type.2.4.a: Invalid content was found starting with element 'display-name'

    cvc-complex-type.2.4.a: Invalid content was found starting with element 'display-name'. One of '{&qu ...

  10. web.xml报错:cvc-complex-type.2.4.a: Invalid content was found starting with element 'async-supported'. One of '{"http://java.sun.com/xml/ns/javaee":init-param}' is expected.

    在写xml的时候又一次总是报cvc-complex-type.2.4.a: Invalid content was found starting with element 错误,还出现小红叉,在网上找 ...

随机推荐

  1. 浅谈forword和sendRedirect

    最近项目中全部用ajax请求数据,导致在做登录过滤器时不能重定向,然后仔细翻了翻Forward和sendRedirect,以下内容收集自百度: 1. forward (服务器端作的重定向) 服务器往c ...

  2. SSH 在ssh-copy-id 之后仍需输入密码的问题

    最近在使用Ansible,基于SSH. 远程服务器IP: 192.168.200.193 以下提及的远程服务器都为该服务器. 远程用户: ansible_user 在本地服务器中,ssh-keygen ...

  3. js的sort(0实现数组的排序

    <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...

  4. vb和c#插入行与删除行

    vb: xSheet.Range(, ).Insert(Shift:=Excel.XlDirection.xlDown) xSheet.Range(, ).Delete() xSheet.Range( ...

  5. 在Android中把内容写到XML文件中

    在Android中把内容写到XML文件中 saveXmlButton.setOnClickListener(new OnClickListener() { @Override public void ...

  6. RedHat7.0更新yum源

    https://blog.csdn.net/hongbin_xu/article/details/79316614

  7. leetcode179

    class Solution { public: string largestNumber(vector<int>& nums) { int n=nums.size(); vect ...

  8. leetcode405

    public class Solution { string ConverToHex(string bit) { var s = ""; switch (bit) { " ...

  9. get提交时中文传值乱码的有关问题

    get提交时中文传值乱码的问题 get提交时中文传值乱码的问题 url=curWarnList.action paramBean.bsIndex=1&paramBean.siteName=萧山 ...

  10. VirtualBox如何扩展虚拟机Ubuntu的硬盘容量?

    一.问题描述 刚刚在VirtualBox中使用Ubuntu虚拟机中,出现了虚拟硬盘不够用的情况.  乖乖,查了一下磁盘空间,如下所示: df -H 原来是上午安装Ubuntu虚拟机的时候,选择了动态分 ...