<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page import="org.springframework.context.ApplicationContext"%> <%@ page import="org.springframework.context.support.ClassPathXmlApplicationContext"%> <%@ page import="com.pegasus827.bean.helloworld" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <% ApplicationContext ctx=new ClassPathXmlApplicationContext("applicationContext.xml"); helloworld hw=(helloworld)ctx.getBean("helloworld"); hw.hello(); %> </body> </html>
spring的基本包要引入,而且你自己定义的包也要引入才能识别类名