Spring做jsp出错误
严重:Servlet.service()forservletjspthrewexceptionorg.apache.jasper.JasperException:Unab...
严重: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 7 in the generated java file
Only a type can be imported. com.zj.service.GoodsService resolves to a package
An error occurred at line: 8 in the generated java file
Only a type can be imported. com.zj.beans.Goods resolves to a package
An error occurred at line: 9 in the generated java file
Only a type can be imported. org.springframework.context.ApplicationContext resolves to a package
An error occurred at line: 10 in the generated java file
Only a type can be imported. org.springframework.context.support.ClassPathXmlApplicationContext resolves to a package
An error occurred at line: 18 in the jsp file: /WebRoot/goods_list.jsp
ApplicationContext cannot be resolved to a type
15: <body>
16: <table>
17: <%
18: ApplicationContext applicationContext = new ClassPathXmlApplicationContext("beans.xml");
19: GoodsService goodsService = (GoodsService)applicationContext.getBean("goodsService");
20: List<Goods> goods = goodsService.getAllGoods();
21: Iterator it = goods.iterator(); 展开
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 7 in the generated java file
Only a type can be imported. com.zj.service.GoodsService resolves to a package
An error occurred at line: 8 in the generated java file
Only a type can be imported. com.zj.beans.Goods resolves to a package
An error occurred at line: 9 in the generated java file
Only a type can be imported. org.springframework.context.ApplicationContext resolves to a package
An error occurred at line: 10 in the generated java file
Only a type can be imported. org.springframework.context.support.ClassPathXmlApplicationContext resolves to a package
An error occurred at line: 18 in the jsp file: /WebRoot/goods_list.jsp
ApplicationContext cannot be resolved to a type
15: <body>
16: <table>
17: <%
18: ApplicationContext applicationContext = new ClassPathXmlApplicationContext("beans.xml");
19: GoodsService goodsService = (GoodsService)applicationContext.getBean("goodsService");
20: List<Goods> goods = goodsService.getAllGoods();
21: Iterator it = goods.iterator(); 展开
6个回答
2015-12-27 · 做真实的自己 用良心做教育
千锋教育
千锋教育专注HTML5大前端、JavaEE、Python、人工智能、UI&UE、云计算、全栈软件测试、大数据、物联网+嵌入式、Unity游戏开发、网络安全、互联网营销、Go语言等培训教育。
向TA提问
关注
展开全部
一般在jsp中出现如下错误:Unable to compile class for JSP是因为jsp上有语法错误导致。
<%@page import="com.pd.Person"%>
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
Student stu=new Student();//使用默认的包,这个会出错
Person p=new Person(); //导入了包,没有问题
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
</html>
<%@page import="com.pd.Person"%>
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
Student stu=new Student();//使用默认的包,这个会出错
Person p=new Person(); //导入了包,没有问题
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
</html>
展开全部
您没导包
在这个jsp文件的第二行插入<%@ page import="org.springframework.context.ApplicationContext;"%>
<%@ page import="org.springframework.context.support.ClassPathXmlApplicationContext;"%>
在这个jsp文件的第二行插入<%@ page import="org.springframework.context.ApplicationContext;"%>
<%@ page import="org.springframework.context.support.ClassPathXmlApplicationContext;"%>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
ApplicationContext ctx = new FileSystemXmlApplicationContext(路径名称);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
ApplicationContext 这个改成org.springframework.context.ApplicationContext
ClassPathXmlApplicationContext这个改成
org.springframework.context.support.ClassPathXmlApplicationContext
如果还不行 你需要导入spring相应的jar包。有什么问题,可以M我。呵呵
ClassPathXmlApplicationContext这个改成
org.springframework.context.support.ClassPathXmlApplicationContext
如果还不行 你需要导入spring相应的jar包。有什么问题,可以M我。呵呵
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你没在页面上导入包吗?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
ApplicationContext包导错了吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询