错误如下
The content of element type "package" must match "(result-types?,interceptors?,default-interceptor-ref?,default-action-ref?,default-class-ref?,global-results?,global-exception-mappings?,action*)".
百度了很久,大部分都说
在package包中有 的配置标签是有顺序的:
result-types
interceptors
default-interceptor-ref
default-action-ref
default-class-ref
global-results
global-exception-mappings
action*(就是所有的action放到最后)
上面的确是大部分都犯过的错,但是我的错误不是这个原因
错误代码
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN""http://struts.apache.org/dtds/struts-2.3.dtd">
<struts><constant name="struts.action.extension" value="do,action,kk"></constant><package name="tjn" extends="struts-default"><!-- 配置使用paramsPrepareParamsStack作为默认的拦截器栈 修改 PrepareInterceptor拦截器alaysInvokePrepare属性为false --><interceptors><interceptor-stack name="tjn"><interceptor-ref name="paramsPrepareParamsStack"><param name="prepare.alwaysInvokePrepare">false</param></interceptor-ref></interceptor-stack></interceptors><default-interceptor-ref name="tjn"></default-interceptor-ref><!-- -使用paramsPrepareParamsStack --><default-interceptor-ref name="paramsPrepareParamsStack"></default-interceptor-ref><action name="goods_selectinfo" class="goodsDao" method="select_info"><result name="goodsinfo">/selectinfo.jsp</result></action><action name="text" class="cgoods" method="select_info"><result name="hello">/selectinfo.jsp</result></action></package>
</struts>
<!-- -->
错误原因是因为有两个default-interceptor-ref标签,实际上这个标签的是唯一的!
<default-interceptor-ref name="**"></default-interceptor-ref>