これは私のeventActionActionSupportクラスです
public class EventAction extends ActionSupport {
protected EventService eventService;
protected String redirectUrl;
public String getRedirectUrl() {
return redirectUrl;
}
public void setRedirectUrl(String redirectUrl) {
this.redirectUrl = redirectUrl;
}
public void setEventService(EventService services) {
this.eventService = services;
}
}
そして、これが私のapplicationContext.xmlからの断片です
<bean id ="eventService" class ="services.EventService" scope ="singleton">
<property name = "sessionFactory" ref = "sessionFactory"/>
</bean>
宣言内のIDを変更する場合を除いて、コードは正常に機能しています。
私の質問<bean id ="eventService">
では、Spring IDをEventActionサポートクラス内のeventServiceインスタンス変数と一致させる必要があるのはなぜですか?id
作成されるBeanの識別子を作成するだけではありませんか?Beanタグ内のIDがEventAction内で同じである必要があるのはなぜですか?ここで、EventActionクラスは構成で言及されていません。