单例类中dao加载不到,为null。
我的配置如下:
public class SystemHelper {private static SystemHelper instance = null; private DAO1 ruleDao ; private static Hashtable buySaleRuleHt = null public void setRuleDao(DAO1 ruleDao) { this.ruleDao = ruleDao; } public static synchronized SystemHelper getInstance() { if (instance == null) instance = new SystemHelper(); return instance; } public synchronized Hashtable getBuySaleRulHt() { if (buySaleRuleHt == null || buySaleRuleHt.isEmpty()) { <span style="color: red;">List list = ruleDao.findAll();//这里的DAO为null</span> WebBuySaleRule bo = null; for (int i = 0; i < list.size(); i++) { bo = (WebBuySaleRule) list.get(i); buySaleRuleHt.put(bo.getRuleId(), bo); } } return buySaleRuleHt; } public synchronized Hashtable reloadBuySaleRuleHt() { buySaleRuleHt.clear(); this.getBuySaleRulHt(); return buySaleRuleHt; }
}
applicationContext.xml
<bean id="Systemhelper" class="com.xinglong.web.util.SystemHelper">
<property name="ruleDao">
<ref bean="DAO1">
</property>
</bean>
//DAO1,已按正常配置
action中调用:
Hashtable kindsHt = SystemHelper.getInstance().getGoldKindHt();
哪位知道该怎样配置