zoukankan      html  css  js  c++  java
  • 【解决方案】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 of '{"http://java.sun.com/xml/ns/javaee":run-as,   "http://java.sun.com/xml/ns/javaee":security-role-r


    【错误源码】

    在springmvc 配置过程中,配置web.xml 中报出异常:

    异常代码如下:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
        http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
        <display-name></display-name>
        <welcome-file-list>
            <welcome-file>index.jsp</welcome-file>
        </welcome-file-list>
        <!-- 配置springmvc核心控制器 -->
        <servlet>
            <servlet-name>springmvc</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <!-- 再启动web容器的时候,实例化servlet对象 -->
            <load-on-startup>1</load-on-startup>
            <init-param>
                <param-name>configLocation</param-name>
                <param-value>classpath:springmvc.xml</param-value>
            </init-param>
        </servlet>
        <servlet-mapping>
            <servlet-name>springmvc</servlet-name>
            <url-pattern>*.do</url-pattern>
        </servlet-mapping>
    </web-app>

    【解决方案】

    错误点:

         <load-on-startup>1</load-on-startup>
            <init-param>
                <param-name>configLocation</param-name>
                <param-value>classpath:springmvc.xml</param-value>
            </init-param>    

    将代码中

    <load-on-startup>1</load-on-startup>

    放在<init-param>标签之下即可:

    <init-param>
           <param-name>configLocation</param-name>
           <param-value>classpath:springmvc.xml</param-value>
     </init-param>  
    <!-- 关键点 --> <load-on-startup>1</load-on-startup>
  • 相关阅读:
    python的生成Jwt
    qq邮箱验证
    DJango反序列化器的参数效验
    python三元运算,继承,help函数 args
    python时间板块,计算取值,math函数
    No migrations to apply. django同步数据库失败
    redis理论部分
    Java入门——day1
    HBO《硅谷》中的二进制码
    复习总表现(每天记录一下)
  • 原文地址:https://www.cnblogs.com/hyhnet/p/5541994.html
Copyright © 2011-2022 走看看