日期:2014-05-17 浏览次数:20706 次
public static UploadFileService uploadFileService;
static {
ApplicationContext ac = new ClassPathXmlApplicationContext("beans.xml");
uploadFileService = (UploadFileService) ac.getBean("uploadFileServiceBean");
}
@Test//(没问题)
public void testupload1() {
UploadFile entity=new UploadFile("1.jpg");
uploadFileService.save(entity);
}
@Test//(空指针异常)
public void testupload2() {
UploadFileServiceBean o=new UploadFileServiceBean();
UploadFile entity=new UploadFile("1.jpg");
o.save(entity);
}
<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ page import="java.util.*" %>
<%@ page import="com.yourcompany.vo.User" %>
<%@ page import="com.yourcompany.service.iface.ChannelService"%>
<%@ page import="org.springframework.web.context.WebApplicationContext"%>
<%@ page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(application);
Userservice service = (UserService) wac.getBean("userService");