不是new 出来的,而是//TestDaoHibernate dao = new TestDaoHibernate();改成:ITestDao =(ITestDao ) WebApplicationContextUtils.
getRequiredWebApplicationContext(this.
getServlet().getServletContext()).getBean("testDao");
记着 要 import org.springframework.web.context.support.*;
<%@ page language="java" import="org.springframework.web.context.support.*,logic.ITestDao" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'MyJsp.jsp' starting page</title>
</head>
<body>
<%
ITestDao dao=(ITestDao ) WebApplicationContextUtils.
getRequiredWebApplicationContext(this.getServletContext()).getBean("testDao");
out.println(dao.getTest(1).getName());
%>
</body>
</html>
可是却报错如下:
An error occurred at line: 12 in the jsp file: /MyJsp.jsp
Generated servlet error:
WebApplicationContextUtils cannot be resolved
这是怎么回事呀?!请大虾指教!!!