日期:2014-05-17 浏览次数:20763 次
public class A { private static A a; private A(){ } public A getInstance(){ if(a == null) a = new A(); return a; } }
------解决方案--------------------
你在xml配置文件配置了BaseDAO吗?
<bean id="dao" class="com.XXX.BaseDAO" abstract="false" lazy-init="default" autowire="default" dependency-check="default"> <property name="sessionFactory"> <ref bean="sessionFactory"></ref> </property> </bean>
------解决方案--------------------
public class BooksContext {
//这个地方是关键
private static ApplicationContext content=new ClassPathXmlApplicationContext("applicationContext.xml");;
public static void getnewsTypeById(HttpServletRequest request) {
SimpleDateFormat sdf=new SimpleDateFormat("yyyy年MM月dd日hh点mm分");
Date date=new Date();
String d=sdf.format(date);
System.out.println(d);
//这个地方是关键
BookService b = (BookService) content.getBean(
"BookServiceImpl");
List<BooksLordType> list = b.getAllBooksLordType();
request.setAttribute("BooksLordTypeList", list);
}