久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

        <bdo id='qZc2S'></bdo><ul id='qZc2S'></ul>

      <small id='qZc2S'></small><noframes id='qZc2S'>

    1. <legend id='qZc2S'><style id='qZc2S'><dir id='qZc2S'><q id='qZc2S'></q></dir></style></legend>
    2. <tfoot id='qZc2S'></tfoot>
      <i id='qZc2S'><tr id='qZc2S'><dt id='qZc2S'><q id='qZc2S'><span id='qZc2S'><b id='qZc2S'><form id='qZc2S'><ins id='qZc2S'></ins><ul id='qZc2S'></ul><sub id='qZc2S'></sub></form><legend id='qZc2S'></legend><bdo id='qZc2S'><pre id='qZc2S'><center id='qZc2S'></center></pre></bdo></b><th id='qZc2S'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='qZc2S'><tfoot id='qZc2S'></tfoot><dl id='qZc2S'><fieldset id='qZc2S'></fieldset></dl></div>

        Spring MVC 中的 @Named 注解

        @Named annotation in Spring MVC(Spring MVC 中的 @Named 注解)

        <legend id='B7gGO'><style id='B7gGO'><dir id='B7gGO'><q id='B7gGO'></q></dir></style></legend>

          • <bdo id='B7gGO'></bdo><ul id='B7gGO'></ul>
          • <small id='B7gGO'></small><noframes id='B7gGO'>

            <i id='B7gGO'><tr id='B7gGO'><dt id='B7gGO'><q id='B7gGO'><span id='B7gGO'><b id='B7gGO'><form id='B7gGO'><ins id='B7gGO'></ins><ul id='B7gGO'></ul><sub id='B7gGO'></sub></form><legend id='B7gGO'></legend><bdo id='B7gGO'><pre id='B7gGO'><center id='B7gGO'></center></pre></bdo></b><th id='B7gGO'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='B7gGO'><tfoot id='B7gGO'></tfoot><dl id='B7gGO'><fieldset id='B7gGO'></fieldset></dl></div>

                    <tbody id='B7gGO'></tbody>
                  <tfoot id='B7gGO'></tfoot>
                  本文介紹了Spring MVC 中的 @Named 注解的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  根據 Spring 3 文檔,IoC容器,@Named注解是標準等價于@Component注解.

                  Per Spring 3 document, The IoC container, the @Named annotation is a standard equivalent to the @Component annotation.

                  由于@Repository@Service@Controller都是@Component,所以我嘗試使用@Named 用于我的 Spring MVC 應用程序中的所有這些.它工作正常.但我發現 @Controller 的替換似乎有一個錯誤.在控制器類中,原來是

                  Since @Repository, @Service, and @Controller are all @Component, I tried to used @Named for all of them in my Spring MVC application. It works fine. But I found the replacement of @Controller seems to have a bug. In the controller class, originally, it was

                  @Controller
                  public class MyController{
                      ...
                  }
                  

                  它工作正常.當我將 @Controller 更改為 @Named

                  It works fine. When I changed @Controller to @Named

                  @Named
                  public class MyController{
                      ...
                  }
                  

                  失敗并出現錯誤:

                  沒有為帶有 URI ... 的 HTTP 請求找到映射".

                  "No mapping found for HTTP request with URI ...".

                  但是如果我將 @RequestMapping 添加到類中,如下所示

                  But if I added @RequestMapping to the class as follow

                  @Named
                  @RequestMapping
                  public class MyController{
                       ...
                   }
                  

                  它會按預期工作.

                  對于 @Repository@Service,我可以簡單地用 @Named 替換它們,沒有任何問題.但是 @Controller 的替換需要額外的工作.配置中有什么我遺漏的嗎?

                  For @Repository and @Service, I can simply replace them with @Named with no issue. But the replacement of @Controller needs extra work. Is there anything I am missing in the configuration?

                  推薦答案

                  @Named@Component 的作用相同.但是,注釋 @Controller@Service@Repository 更具體.

                  @Named works the same as @Component. However, the annotations @Controller, @Service, and @Repository are more specific.

                  來自 Spring 文檔:

                  From the Spring docs:

                  @Component 是任何 Spring 管理的組件的通用構造型.@Repository@Service@Controller@Component 用于更具體的用例,例如,在分別是持久層、服務層和表示層.

                  @Component is a generic stereotype for any Spring-managed component. @Repository, @Service, and @Controller are specializations of @Component for more specific use cases, for example, in the persistence, service, and presentation layers, respectively.

                  例如,這些原型注釋是理想的目標切入點.@Repository@Service@Controller 可能會在未來版本的春天框架.因此,如果您在使用 @Component 之間進行選擇或 @Service 為您的服務層,@Service 顯然更好選擇.同樣,如上所述,@Repository 已經被支持作為持久性中自動異常翻譯的標記層.

                  For example, these stereotype annotations make ideal targets for pointcuts. It is also possible that @Repository, @Service, and @Controller may carry additional semantics in future releases of the Spring Framework. Thus, if you are choosing between using @Component or @Service for your service layer, @Service is clearly the better choice. Similarly, as stated above, @Repository is already supported as a marker for automatic exception translation in your persistence layer.

                  本部分解釋了與 @Named 的區別.

                  This section explains the difference with @Named.

                  許多組件,例如 Spring 的 DispatcherServlet(WebApplicationContext 中的 MVC 配置)不是在尋找 Component,而是在尋找 @控制器.所以當它掃描你的類時,它不會在 @Named 中找到它.以類似的方式,使用 @Transactional 的事務管理查找 @Service@Repository,而不是更通用的 @Component.

                  Many components, like Spring's DispatcherServlet (MVC configuration in WebApplicationContext) aren't looking for Component, they are looking for @Controller. So when it scans your class, it won't find it in @Named. In a similar fashion, transaction management with @Transactional looks for @Service and @Repository, not for the more generic @Component.

                  這篇關于Spring MVC 中的 @Named 注解的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  quot;Char cannot be dereferencedquot; error(“Char 不能被取消引用錯誤)
                  Java Switch Statement - Is quot;orquot;/quot;andquot; possible?(Java Switch 語句 - 是“或/“和可能的?)
                  Java Replace Character At Specific Position Of String?(Java替換字符串特定位置的字符?)
                  What is the type of a ternary expression with int and char operands?(具有 int 和 char 操作數的三元表達式的類型是什么?)
                  Read a text file and store every single character occurrence(讀取文本文件并存儲出現的每個字符)
                  Why do I need to explicitly cast char primitives on byte and short?(為什么我需要在 byte 和 short 上顯式轉換 char 原語?)

                    <i id='C38GH'><tr id='C38GH'><dt id='C38GH'><q id='C38GH'><span id='C38GH'><b id='C38GH'><form id='C38GH'><ins id='C38GH'></ins><ul id='C38GH'></ul><sub id='C38GH'></sub></form><legend id='C38GH'></legend><bdo id='C38GH'><pre id='C38GH'><center id='C38GH'></center></pre></bdo></b><th id='C38GH'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='C38GH'><tfoot id='C38GH'></tfoot><dl id='C38GH'><fieldset id='C38GH'></fieldset></dl></div>
                      <tbody id='C38GH'></tbody>

                    1. <legend id='C38GH'><style id='C38GH'><dir id='C38GH'><q id='C38GH'></q></dir></style></legend>

                    2. <tfoot id='C38GH'></tfoot>
                        <bdo id='C38GH'></bdo><ul id='C38GH'></ul>
                        • <small id='C38GH'></small><noframes id='C38GH'>

                            主站蜘蛛池模板: 欧美黄视频 | 亚洲深夜福利 | 男女又爽又黄视频 | 亚洲天堂一区 | 日本久久久久久 | 国产一区二区欧美 | 99re6在线视频 | 华丽的挑战在线观看 | 国产精品毛片无码 | 久久久久久久久毛片 | 日韩av成人在线 | 日本三级黄视频 | 国产成人自拍av | 九九免费观看视频 | 二区三区视频 | 欧美一区在线视频 | 天天爽夜夜骑 | 不卡在线视频 | 欧美一区二区 | 91精品国产综合久久福利软件 | 亚洲精品在线视频 | 久久免费资源 | 91久久精品一区二区二区 | 欧美激情久久久 | 久久精品亚洲 | 国产精品美女久久久久aⅴ国产馆 | 在线观看国产视频 | 成人精品福利 | 亚洲欧美一区二区三区国产精品 | 国产一区二区三区在线视频 | 国产在线观看一区二区 | 国产一区二区三区视频在线观看 | 在线看亚洲 | 一区二区三区视频免费看 | 亚洲成人免费电影 | 色视频免费 | 亚洲天堂色 | 成年无码av片在线 | 日本免费黄色 | 欧美国产日韩一区二区三区 | 久久99精品久久久久久国产越南 |