レベルエンター山本大のブログ

面白いプログラミング教育を若い人たちに

BLOCKVROCKリファレンス目次はこちら

[翻訳]Guice User's Guide ■31. Struts 2 Support

Struts 2 サポート

To install the Guice Struts 2 plugin with Struts 2.0.6 or later, simply include guice-struts2-plugin-1.0.jar in your web application's classpath and select Guice as your ObjectFactory implementation in your struts.xml file:

GuiceStruts 2.0.6以降を使ってStruts2プラグインをインストールするには、単にWebアプリケーションのクラスパスに「guice-struts2-plugin-1.0.jar」を含めるだけです。そして、struts.xml ファイルでObjectFactoryの実装として、Guiceを選んでください。

<constant name="struts.objectFactory" value="guice" />

Guice will inject all of your Struts 2 objects including actions and interceptors. You can even scope your actions. You can optionally specify a Module for Guice to install in your struts.xml file:

GuiceはActionやインターセプターを含むStruts2のすべてのオブジェクトをインジェクトしてくれます。アクションのスコープを均一にする事が出来ます。struts.xmlファイルでインストールするために、Guiceのモジュールを指定することもできます。

<constant name="guice.module" value="mypackage.MyModule"/>

If all of your bindings are implicit, you can get away without defining a module at all.

すべてのバインディングが暗黙的なら、モジュールを全く記述しないことも可能です。