-1

我的 struts-config.xml 中出现以下错误

严重:第 6 行第 16 列解析错误:文档根元素“struts-config”,必须匹配 DOCTYPE 根“form-validation”。org.xml.sax.SAXParseException;systemId: jndi:/localhost/SSH/WEB-INF/struts-config.xml;行号:6;列号:16;文档根元素“struts-config”,必须匹配 DOCTYPE root“form-validaton”

xml:

 <?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE form-validation PUBLIC
                 "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.3.0//EN" "http://jakarta.apache.org/commons/dtds/validator_1_3_0.dtd">  
        <struts-config>
        <form-beans>
        <form-bean name="sform" type="org.apache.struts.action.DynaActionForm">
        <form-property name="sid" type="java.lang.String"/>
        </form-bean>
        </form-beans>
        <global-exceptions/>
        <global-forwards/>
        <action-mappings>
        <action path="/sidSubmit" name="sform" 
        type="org.springframework.web.struts.DelegatingActionProxy" 
        scope="request" 
        input="/search.jsp">
        <forward name="search" path="/search.jsp"/>
        </action>
        </action-mappings>
        <message-resources parameter="com.xxx.xxx.Application"></message-resources>
        <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
        <set-property property="contextConfigLocation" value="/WEB-INF/studentContext.xml"/>
        </plug-in>
        </struts-config>
4

1 回答 1

1

你把这个文件复制粘贴在一起了吗?它声明了一个有关表单验证的 DOCTYPE,但包含 Struts 1.x Web 应用程序的配置。

为 Struts 配置文件使用正确的 DOCTYPE(来自规范):

<!DOCTYPE struts-config PUBLIC
  "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
  "http://struts.apache.org/dtds/struts-config_1_3.dtd">

假设这里是 Struts 1.3.x,您可能需要更改 DOCTYPE 声明中引用的版本。

于 2013-12-19T16:29:13.527 回答