<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # [已解決] 無法找到`ref-name`引用的攔截器類 > 原文: [https://howtodoinjava.com/struts2/solved-unable-to-find-interceptor-class-referenced-by-ref-name/](https://howtodoinjava.com/struts2/solved-unable-to-find-interceptor-class-referenced-by-ref-name/) 在為[**`@InterceptorRef`示例**](//howtodoinjava.com/struts-2/struts-2-custom-interceptor-with-interceptorref-example/ "Struts2 custom interceptor with @InterceptorRef example")編寫代碼時,我才知道此功能。 我必須在`struts.xml`文件中聲明攔截器定義,而我想通過注解使用攔截器。 第一次嘗試時,失敗并顯示以下錯誤: ```java Unable to load configuration. - [unknown location] at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70) at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:446) at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:490) Caused by: Unable to find interceptor class referenced by ref-name customStack - [unknown location] at com.opensymphony.xwork2.config.providers.InterceptorBuilder.constructInterceptorReference(InterceptorBuilder.java:63) at org.apache.struts2.convention.DefaultInterceptorMapBuilder.buildInterceptorList(DefaultInterceptorMapBuilder.java:95) at org.apache.struts2.convention.DefaultInterceptorMapBuilder.build(DefaultInterceptorMapBuilder.java:86) at org.apache.struts2.convention.DefaultInterceptorMapBuilder.build(DefaultInterceptorMapBuilder.java:64) ``` ## 原因: 默認情況下,`Convention`插件使用其自己的包`Convention-default`,其中不包含您在`struts.xml`中定義的包。 這意味著`Convention`將在其中放置您的操作的包不會擴展定義攔截器的包。 ![Random exceptions](https://img.kancloud.cn/81/c9/81c97e6ebb55a2bdb88e52750e274fe3_300x350.png) 隨機異常 ## 解決方案 要更改,您有兩個選擇: 1) 使用`@ParentPackage`注解 2) 在`struts.xml`中定義`<constant name=”struts.convention.default.parent.package” value=”default”/ >` 例如: ```java <struts> <package name="default" namespace="/" extends="struts-default"> <interceptors> <interceptor name="demoCustomInterceptor" class="com.howtodoinjava.struts2.example.web.DemoCustomInterceptor" /> <interceptor-stack name="customStack"> <interceptor-ref name="demoCustomInterceptor"/> <interceptor-ref name="defaultStack" /> </interceptor-stack> </interceptors> </package> <constant name="struts.convention.result.path" value="/WEB-INF/jsp/" /> <constant name="struts.devMode" value="true" /> <constant name="struts.action.extension" value="action," /> <constant name="struts.custom.i18n.resources" value="test" /> <constant name="struts.convention.default.parent.package" value="default"/> </struts> ``` 這樣可以解決問題。 **祝您學習愉快!**
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看