<%@page import="com.msAccess.service.impl.NewspaperServiceImpl"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="com.msAccess.service.NewspaperService"%>
<%@ page language="java" contentType="text/html;charset=utf-8"%>
<%@ page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@ page import="org.springframework.web.context.WebApplicationContext"%>
<%@ page import="com.msAccess.vo.Newspaper" %>
<%
String path2 = request.getContextPath();
String basePath2 = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path2+"/";
ServletContext context = request.getSession().getServletContext();
WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(context);
NewspaperService newspaperService = (NewspaperServiceImpl)wac.getBean("newspaperService");
List<Object> newspaperList = new ArrayList<Object>();
String hql = "from Newspaper where '1'=?";
newspaperList = newspaperService.findNewspapersByHQL(hql, new Object[]{"1"});
int i = newspaperList.size();
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="com.msAccess.service.NewspaperService"%>
<%@ page language="java" contentType="text/html;charset=utf-8"%>
<%@ page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@ page import="org.springframework.web.context.WebApplicationContext"%>
<%@ page import="com.msAccess.vo.Newspaper" %>
<%
String path2 = request.getContextPath();
String basePath2 = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path2+"/";
ServletContext context = request.getSession().getServletContext();
WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(context);
NewspaperService newspaperService = (NewspaperServiceImpl)wac.getBean("newspaperService");
List<Object> newspaperList = new ArrayList<Object>();
String hql = "from Newspaper where '1'=?";
newspaperList = newspaperService.findNewspapersByHQL(hql, new Object[]{"1"});
int i = newspaperList.size();
%>
代码如上,但首先需要在项目中添加spring-web-3.2.0.M2.jar包