编辑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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>address</display-name>
<servlet>
<servlet-name>address</servlet-name>
<servlet-class>address.servlet.AddressServlet</servlet-class>
<load-on-startup>0</load-on-startup>
<init-param><!-- 这一行出现红xx提示-->
<param-name>ref1</param-name>
<param-value>value</param-value>
</init-param>
<init-param>
<param-name>ref2</param-name>
<param-value>value2</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>address</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'. 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>0</load-on-startup> 移动到最后即可.
附图: