Spring Frameworkの今 (2013年版) #jjug_ccc #ccc_r17 #springframework
Spring MVC 3.0/3.1/3.2の日本語の実用レベルのまとまった情報が少ないので、ドキュメントとして、クックブック的なレシピ集としてまとめたものとして公開します。 まだ、書きかけのところもありますが、Spring MVCの大体の機能は説明できていると思います。 基本的に、自分が使っている機能をまとめています。 Spring MVCに直接関係しないものも多々あります。書いていたら、いつの間にか増えてました(JAXBやRELAX NGとか)。 今後も主にこの方針で更新していきますが、ページ数が多くなった場合、分割するかもしれません。 目指すところ Webアプリケーションを作成するときに、フレームワークの選定する際の候補としてSpring MVCも入れてほしいので、その参考資料としても使えるようにする。また、目次をみれば、Spring MVCで何ができるのかできるだけわかるようにする
Spring Frameworkはもともと、面倒なJavaEE環境における開発を簡易化する軽量のDIコンテナーとして有名になったので、あまり、そういうイメージがないのですが、実は、JavaSEのAPIを簡易化するためのライブラリーとしてもかなり良く設計されていると思います。実際、Springは低結合性、高凝集性、インターフェースに対するコーディングなどオブジェクト指向の設計がかなり徹底されているため、部分的な部品のつまみ食いも比較的容易なのです。ここでは、意外に知られていないSpring FrameworkのJavaSE簡易化機能についていくつか紹介したいと思います。これらの機能を流用して使いこなすことで、Webアプリケーションに限らず、さまざまなプログラムでJava言語を使った開発の生産性を向上させることができると思います。 JavaBeansに対するプロパティアクセスの簡易化 Spri
JSF2.0やSeamなど、新しいフレームワークではフラッシュスコープという機能を利用することができます。これはもともとRuby on Railsで有名になった処理方式だと考えられますが、フラッシュにデータを登録しておくと一回のHTTPリダイレクトの最中のみデータが保持され、次回以降のリクエスト時までに自動的に削除されます。従来こうした仕掛けをHTTPセッションを使ってアプリロジック中で毎回個別に実現するのは結構面倒で、またデータが正しくクリアされずに残存するなどのバグも簡単に発生しがちでした。 以前はあまり知られていませんでしたが、2重送信の問題を回避するために、最近はPRG(Post/Redirect/Get)パターンというのがよく知られるようになっています。*1このパターンでは、POSTリクエストで画面遷移する場合は、間にリダイレクトとGETをはさむことでURLバーのアドレス表示と実
バージョン3以降のSpring MVCでは、コントローラーのメソッドからJSON文字列を簡単に返却させることができます。以前のバージョンでもビュークラスを独自に拡張することでJSONの返却は一応可能でしたが、最新バージョンでは非常に簡単にJSON対応させることができ、Ajaxライブラリーを使ったWebアプリケーションやサービスの開発が容易になっています。 Ajax Simplifications in Spring 3.0 コントローラーをJSON対応させる手順 コントローラーをJSON対応させるためには、まず、JacksonというJSON処理ライブラリーをクラスパスに通す必要があります。Mavenを使う場合は、pomに以下を追加します。 <dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-cor
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く