Skip to Content
Spring Boot:立ち上げて実行する
book

Spring Boot:立ち上げて実行する

by Mark Heckler
March 2025
Beginner to intermediate
328 pages
5h 36m
Japanese
O'Reilly Media, Inc.
Content preview from Spring Boot:立ち上げて実行する

第7章. Spring MVCを使ってアプリケーションを作成する

この作品はAIを使って翻訳されている。ご意見、ご感想をお待ちしている:translation-feedback@oreilly.com

この章では、RESTインタラクション、メッセージングプラットフォーム、その他の通信メカニズムを持つSpring MVCを使ってSpring Bootアプリケーションを作成する方法を示し、テンプレート言語のサポートについて紹介する。前章でSpring Bootのデータを扱う多くのオプションの一部としてサービス間の対話を紹介したが、この章ではアプリケーション自身から外界、つまり他のアプリケーションやサービス、エンドユーザとの対話に主な焦点を移す。

コード・チェックアウト

まずは、コード・リポジトリからブランチchapter7beginをチェックしてほしい。

Spring MVC:それは何を意味するのか?

テクノロジーにおける他の多くの事柄と同様に、Spring MVCという用語はややオーバーロードである。誰かがSpring MVCに言及するとき、彼らは次のいずれかを意味する可能性がある:

  • Springアプリケーションでモデル-ビュー-コントローラパターンを(何らかの方法で)実装する

  • Model インタフェース、@Controller クラス、ビューテクノロジーなどのSpring MVCコンポーネントの概念を具体的に使用してアプリケーションを作成する。

  • Springを使用したブロック/非反応アプリケーションの開発

文脈によって、Spring MVCはアプローチとも実装とも考えられる。また、Spring Boot内でもSpring Bootなしでも使える。Springを使ったMVCパターンの一般的な適用と、Spring Boot以外でのSpring MVCの使用は、どちらも本書の範囲外である。Spring Bootを使って実装する、先にリストアップした最後の2つの概念に特に焦点を当てる。

テンプレートエンジンを使ったエンドユーザ対話

Spring Bootアプリケーションはバックエンドで多くの重労働を処理するが、Bootはエンドユーザとの直接対話もサポートする。Java Server Pages (JSP)のような古くからある標準はレガシーアプリケーションではまだBootでサポートされているが、現在のアプリケーションのほとんどは、進化し保守され続けているテンプレートエンジンでサポートされるより強力なビューテクノロジを活用するか、フロントエンド開発をHTMLとJavaScriptの組み合わせにシフトしている。2つのオプションをうまくミックスして、それぞれの強みを発揮することも可能だ。

Spring Bootは、この章の後半で示すように、HTMLやJavaScriptのフロントエンドとうまく連携する。とりあえず、テンプレートエンジンを詳しく見てみよう。

テンプレートエンジンは、いわゆるサーバ側アプリケーションが、エンドユーザのブラウザに表示され実行される最終ページを生成する方法を提供する。これらのビュー・テクノロジーはアプローチが異なるが、一般的に以下のようなものを提供する:

  • 期待される結果を生成するためにテンプレート・エンジンが使用する入力を定義する、テンプレート言語および/またはタグのコレクション。

  • 要求されたリソースを満たすために使用するビュー/テンプレートを決定するビューリゾルバー。

あまり使われていないオプションとして、Spring ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

実用 Git 第3版

実用 Git 第3版

Prem Kumar Ponuthorai, Jon Loeliger, 萬谷 暢崇, 長尾 高弘
Javaによる関数型プログラミング ―Java 8ラムダ式とStream

Javaによる関数型プログラミング ―Java 8ラムダ式とStream

Venkat Subramaniam, 株式会社プログラミングシステム社
Java 開発者向け DevOps ツール

Java 開発者向け DevOps ツール

Stephen Chin, Melissa McKay, Ixchel Ruiz, Baruch Sadogursky

Publisher Resources

ISBN: 9798341626911