私のプロジェクトでは、struts2 と spring を使用しました。Spring は DI のためだけに使用されます。私はすべてのアクションをセッションによって作成しているので、Spring DI を介してモデル Bean として作成しています。今、私は自分のクラスに継承を使用したいと考えています。これは aop ベースのプロキシを介して生成され、セッションごとになります。コーディングは以下のようになります。
<bean id="common.EshopDefaultAction" class="com.common.actions.EshopDefaultAction" scope="session" >
<property name="site" ref="master.site" />
<property name="menu" ref="master.menu" />
<property name="indexDAO" ref="common.indexDAO" />
<property name="categoryDAO" ref="master.categoryDAO" />
<property name="productDAO" ref="master.productDAO" />
</bean>
<bean id="common.IndexAction" parent="common.EshopDefaultAction" class="com.common.actions.IndexAction" scope="session">
<property name="indexInfo" ref="common.indexInfo" />
<aop:scoped-proxy />
</bean>
どちらのアクションにもセッターとゲッターのペアがあります。上記の IndexAction のようなすべての子のセッションによって作成された site、menu、indexDAO、categoryDAO、productDAO オブジェクトが必要です。現在、 と に対して異なるオブジェクトを作成していEshopDefaultAction
ますIndexAction
。
Bean 定義に追加する<aop:scoped-proxy />
と、次のようなエラーが発生しますEshopDefaultAction
Invalid property 'targetBeanName' of bean class [com.common.actions.IndexAction]:
Bean property 'targetBeanName' is not writable or has an invalid setter method.
Does the parameter type of the setter match the return type of the getter?