<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 156,  comments - 601,  trackbacks - 0
     最近在Spring官網上發現,Spring 2.5發布不久,Spring3.0項目已經是開始進行了。

    包括很多新功能,如標題中提到的Restful的支持,還有Servlet3.0的支持等。
    大概總結了一下,Spring3.0中會包括以下一些新特性:
    • 1. Full scale REST support by means of additions to the Spring MVC API - already pretty detailed, and apparently going to be included in the first milestone release
    • 2. Support for Unified EL (as seen in Spring Web Flow) - very likely part of 3.0, but no details given
    • 3. Annotation support for declaring factory methods - as above
    • 4 .Support for Portlet 2.0 (JSR 286), including resource requests (ResourceServingPortlet) - as above
    • 5. "Preparations" for Servlet 3.0 specification - sounded a lot like architectural preparations not visible to the "consumer"
    • 6. Something to fill the gap between Spring Web Flow and Spring MVC - that sounded very vague
    • 7. Inclusion (probably generalisation) of the repeat, retry and resume semantics provided by Spring Batch - was only hinted at, no details given
    • 8. Inclusion of the OXM support provided by Spring WS - sounded pretty definitive, but no details given
    • 9. Some kind of site definition language for the web stack - no idea whether this is more than a rumour
    • 10. Model-based validation for use both in server and client - as above

    下面我們具體介紹一下Restful該特性.
      剛才我也提到了,Spring3.0是基于其目前提供的Spring MVC框架上引入對Rest的支持,這樣使其可以很好的融合到Spring中。
      下面有一段代碼,大家看了會更有體會。
       先看一下如何發布Rest風格的服務接口
    1 @RequestMapping(value = "/gadgets/{id}",
    2       method = RequestMethod.GET)
    3 public View getGadget(@PathParam String id) {
    4   // 功能是根據 id 查詢 Gadget對象
    5   // 返回View對象
    6 }
    7 
       看到使用Annotation方式,代碼非常簡潔。@RequestMapping是對訪求的資源進行服務的綁定, value指定服務的資源路徑, method是指Rest風格中的CRUD的方法。
       @PathParam是對資源路么參數的解析,它會自動根據提交的數據格式,解析參數值。

       下面來看一下RestTemplate,對Rest服務接口的調用.
     
     1 // 使用getForObject執行查詢操作
     2 //  (指定參數提交方式)
     3 RestTemplate template = new RestTemplate();
     4 Gadget gadget = template.getForObject(
     5     "http://www.springify.com/gadgets/{id}",
     6     Gadget.class1);
     7 
     8 // 使用postForLocation 執行新增操作
     9 // (指定參數提交方式,使用Map對象)
    10 Map<String, String> params =
    11     new HashMap<String, String>();
    12 params.put("id"42);
    13 URI uri = template.postForLocation(
    14     "http://www.springify.com/gadgets/{id}/features",
    15     new Feature("Glows in the dark."), params);
    16 
    17 // 刪除操作的演示
    18 template.delete(
    19     "http://www.springify.com/gadgets/{id}", someId);
    20 
    21
    29 

    總結:可以看到使用Rest風格的服務發布,可以對服務資源進行統一的管理,使用發布的接口更清晰。

    當然在Spring 3.0 發布之前,上述的API,annotation可能會有變動,我們也期待Spring能與我們早日見面。

    最后,由于本人對Rest技術了解還不是太深入,也希望大家能多提些意見和建議。

    Good Luck!
    Yours Matthew!

    posted on 2008-09-02 19:32 x.matthew 閱讀(4812) 評論(4)  編輯  收藏 所屬分類: 最新開源動態Spring|Hibernate|Other framework
    主站蜘蛛池模板: 亚洲一区二区三区乱码A| 免费国产在线观看| 亚洲黄色免费在线观看| 在线观看免费黄色网址| 亚洲精品乱码久久久久久蜜桃不卡 | 亚洲av无码电影网| 四虎免费影院ww4164h| 亚洲精品网站在线观看你懂的| 亚洲成a人片在线观看久| 国产精品亚洲色婷婷99久久精品| 在线A级毛片无码免费真人| 亚洲精品天堂成人片AV在线播放| 全免费一级毛片在线播放| 亚洲欧美日韩中文字幕一区二区三区 | 亚洲国产综合无码一区| 你懂的免费在线观看网站| 久久精品亚洲中文字幕无码麻豆| 亚洲一区免费在线观看| 国产亚洲精品VA片在线播放| 成人毛片18女人毛片免费视频未 | 亚洲国产电影在线观看| 大陆一级毛片免费视频观看| 水蜜桃视频在线观看免费| 亚洲色婷婷六月亚洲婷婷6月| 午夜精品射精入后重之免费观看 | 久久www免费人成精品香蕉| 久久精品国产亚洲av麻| 青青草a免费线观a| 老妇激情毛片免费| 国产亚洲人成无码网在线观看| 亚洲成人免费网站| 亚洲爆乳无码专区www| 亚洲乳大丰满中文字幕| 免费不卡视频一卡二卡| 无码 免费 国产在线观看91| 亚洲伦另类中文字幕| 手机看片久久国产免费| 国内少妇偷人精品视频免费| 久久亚洲精品国产亚洲老地址 | 666精品国产精品亚洲 | 羞羞视频网站免费入口|