问题
struts-config.xml中的<global-exceptions>异常处理程序示例。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_3.dtd">
<struts-config>
<global-exceptions>
<exception
key="error.io.key"
type="java.io.IOException"
path="/error.jsp" />
</global-exceptions>
<form-beans>
<form-bean name="dynaUserForm"
type="org.apache.struts.action.DynaActionForm">
<form-property name="username" type="java.lang.String"/>
</form-bean>
</form-beans>
<action-mappings>
//...
</action-mappings>
</struts-config>
部署期间,提示org.apache.commons.digester.Digester错误。
19 April 2010 6:50:13 PM org.apache.commons.digester.Digester error
SEVERE: Parse Error at line 52 column 17: The content of element type
"struts-config" must match "(display-name?,description?,form-beans?,
global-exceptions?,global-forwards?,action-mappings?,controller?,
message-resources*,plug-in*)".
<global-exceptions>语法绝对正确,您发现错误了吗?
解
struts-config.xml“ 必须 ”的元素以正确的顺序显示。 再次看到错误消息:
"struts-config" must match
display-name?,
description?,
form-beans?,
global-exceptions?,
global-forwards?,
action-mappings?,
controller?,
message-resources*,
plug-in*
<form-beans>必须出现在<global-exceptions>之前 。 您需要将struts-config.xml更改为以下顺序:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_3.dtd">
<struts-config>
<form-beans>
<form-bean name="dynaUserForm"
type="org.apache.struts.action.DynaActionForm">
<form-property name="username" type="java.lang.String"/>
</form-bean>
</form-beans>
<global-exceptions>
<exception
key="error.io.key"
type="java.io.IOException"
path="/error.jsp" />
</global-exceptions>
<action-mappings>
//...
</action-mappings>
</struts-config>
标签: Struts
翻译自: https://mkyong.com/struts/struts-global-exception-xml-parsing-exception/