当前位置: 代码迷 >> Web前端 >> cvc-complex-type.2.4.a:在WEB.XML中的有关问题
  详细解决方案

cvc-complex-type.2.4.a:在WEB.XML中的有关问题

热度:900   发布时间:2012-11-12 12:31:56.0
cvc-complex-type.2.4.a:在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"
    version="2.4">
<servlet>
   <servlet-name>simple</servlet-name>
   <servlet-class>chen.hao.cn.servlet.SimpleServlet</servlet-class>
</servlet>
<servlet>
   <servlet-name>life</servlet-name>
   <servlet-class>chen.hao.cn.servlet.LifeCycleServlet</servlet-class>
   <load-on-startup>1</load-on-startup>
</servlet>

<servlet>
   <servlet-name>param</servlet-name>
   <servlet-class>chen.hao.cn.servlet.InitParameterServlet</servlet-class>
    <load-on-startup>3</load-on-startup>
   <init-param>
      <param-name>ref1</param-name>
      <param-value>CHEN</param-value>
   </init-param>
   <init-param>
      <param-name>ref2</param-name>
      <param-value>HAO</param-value>
   </init-param>

</servlet>
<servlet-mapping>
    <servlet-name>param</servlet-name>
    <url-pattern>/ipar</url-pattern>
</servlet-mapping>


<servlet-mapping>
    <servlet-name>life</servlet-name>
    <url-pattern>/lc</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>simple</servlet-name>
    <url-pattern>/demo</url-pattern>
</servlet-mapping>

   <servlet-mapping>
    <servlet-name>simple</servlet-name>
    <url-pattern>/demo.chen</url-pattern>
</servlet-mapping>

   <servlet-mapping>
    <servlet-name>simple</servlet-name>
    <url-pattern>/demo/*</url-pattern>
</servlet-mapping>
</web-app>
显示的错误为:cvc-complex-type.2.4.a: Invalid content was found starting with element 'init-
param'. One of '{"http://java.sun.com/xml/ns/j2ee":run-as, "http://java.sun.com/
xml/ns/j2ee":security-role-ref}' is expected.

改错方法;把<load-on-startup>3</load-on-startup>这行代码放在

<init-param>
      <param-name>ref1</param-name>
      <param-value>CHEN</param-value>
   </init-param>
   <init-param>
      <param-name>ref2</param-name>
      <param-value>HAO</param-value>
   </init-param>

上述代码末端即可~~~~~~~~~~~~~~~~
  相关解决方案