Upgrade to Pro — share decks privately, control downloads, hide ads and more …

再入門!RESTとSpringMVC

terahide
January 21, 2014

 再入門!RESTとSpringMVC

2014/1/21 JJUG ナイトセミナーの資料です

terahide

January 21, 2014
Tweet

More Decks by terahide

Other Decks in Programming

Transcript

  1. Web Web( (HTTP HTTP) ) 1 Request 1 Request 1

    Request 1 Request 2 Response 2 Response 2 Response 2 Response 世界中で一意なアドレス (URL URL URL URL) ファイル(HTML HTML HTML HTMLなど)
  2. Web WebApplication Application 1 Request 1 Request 1 Request 1

    Request 2 Response 2 Response 2 Response 2 Response CGI CGI CGI CGI Servlet Servlet Servlet Servlet etc. etc. etc. etc. URL URL URL URLで期待する処理を指定 処理結果(HTML HTML HTML HTMLなど)
  3. MVC MVC2 2 Controller Controller Controller Controller View View View

    View Model Model Model Model 1 Request 1 Request 1 Request 1 Request 2 Response 2 Response 2 Response 2 Response Requst Mapping Requst Mapping Requst Mapping Requst Mapping HTTP Parameter HTTP Parameter HTTP Parameter HTTP Parameter etc. etc. etc. etc. Business Logic Business Logic Business Logic Business Logic Business Data Business Data Business Data Business Data etc. etc. etc. etc. HTML Template HTML Template HTML Template HTML Template etc. etc. etc. etc.
  4. SpringMVC SpringMVCの動作概要 の動作概要 DispatcherServlet DispatcherServlet DispatcherServlet DispatcherServlet HandlerMapping HandlerMapping HandlerMapping

    HandlerMapping Controller Controller Controller Controller ViewResolver ViewResolver ViewResolver ViewResolver ① ③-2 -2 -2 -2 ビジネス ロジック ③-1 -1 -1 -1 ②-2 -2 -2 -2 凡例 Xxx Xxx Xxx Xxx アプリケーション開発者が 開発するオブジェクト Xxx Xxx Xxx Xxx Spring MVC Spring MVC Spring MVC Spring MVCが用意する オブジェクト View View View View ⑥ ビュー(JSP JSP JSP JSP) ②-1 -1 -1 -1 ④ return return return return return return return return ⑦-2 -2 -2 -2 Model Model Model Model ⑦-1 -1 -1 -1 ⑤
  5. • 設計様式 REST REST (例) (例) 1 Request 1 Request

    1 Request 1 Request 2 Response 2 Response 2 Response 2 Response リソースを世界中で一意な アドレスで指定 処理をメソッドで指定 処理結果 (json json json json、xml xml xml xmlなど)
  6. REST REST (例) (例) URL URL URL URL メソッド 説明

    /item GET アイテムの一覧の取得 /item/1001 GET 指定されたID(1001)のアイテム の詳細を取得 /item/1001 POST 指定されたアイテムの新規作成 /item/1001 PUT 指定されたアイテムの更新 /item/1001 DELETE 指定されたアイテムの削除
  7. REST RESTの利用 の利用 (例) (例) 1 Request 1 Request 1

    Request 1 Request 2 Response 2 Response 2 Response 2 Response HTML HTML HTML HTML要求 json json json json 3 Request 3 Request 3 Request 3 Request 4 Response 4 Response 4 Response 4 Response REST REST REST REST HTML HTML HTML HTML ajax ajax ajax ajax
  8. 昨今の 昨今のSpring Spring事情 事情 • Spring Framework 4.0 – first

    to fullysupport Java 8 features • lambda expressions • java.time (JSR-310) • @Repeatable • debug information – remove many deprecated classes and methods • All deprecated packages, and many deprecated classes and methods have been removed with version 4.0.
  9. Spring Framework Spring Framework 4 4.0 .0 • New Features

    – Improved Getting Started Experience – Removed Deprecated Packages and Methods – Java 8 (as well as 6 and 7) – Java EE 6 and 7 – Groovy Bean Definition DSL – Core Container Improvements – General Web Improvements – WebSocket, SockJS, and STOMP Messaging – Testing Improvements