[code="java"]
<bean id="fnBean" class="com.lopu.framework.modules.maintain.action.FlightNatureAction" scope="prototype">
<property name="fnService">//此name必须是iService吗???
<ref bean="iService" />
</property>
</bean>
[/code]
[code="java"]public class FlightNatureAction extends ActionSupport implements
ModelDriven {
private IService fnService;
private List<FlightNature> fnLists = new ArrayList<FlightNature>();
private FlightNature fnBean = new FlightNature();
public IService getFnService() {
return fnService;
}
public void setFnService(IService fnService) {
this.fnService = fnService;
}
public List<FlightNature> getFnLists() {
return fnLists;
}
public void setFnLists(List<FlightNature> fnLists) {
this.fnLists = fnLists;
}
@SuppressWarnings("unchecked")
public String list() throws Exception {
//如果这样写会报NPE,即fnService没注入成功,但我把整段程序中的fnService改为iService,并改下配置文件就一切正常了
this.fnLists = this.fnService.loadAll(FlightNature.class);
return SUCCESS;
}
public FlightNature getModel() {
return this.fnBean;
}
}[/code]
本人spring菜鸟,多多指教。。。