关于jsp中的Unable to compile class for JSP解决

来源:互联网 发布:client mac and addr 编辑:程序博客网 时间:2024/06/06 03:35

我在一个ajax项目中引用了xml,在写到
Document xmlDoc = (Document)new XPPReader().read(new ByteArrayInputStream(xml.getBytes()));
的时候,出现

  1. Multiple annotations found at this line:  
  2.     - The type org.gjt.xpp.XmlPullParserException cannot be resolved. It is indirectly referenced from   
  3.      required .class files  
  4.     - The method read(InputStream) from the type XPPReader refers to the missing type XmlPullParserException  
  5.     - The type org.gjt.xpp.XmlPullParserException cannot be resolved. It is indirectly referenced from   
  6.      required .class files  
  7.     - The method read(InputStream) from the type XPPReader refers to the missing type XmlPullParserException  
然后百度了一下,说是要加载pull-parser-2.1.10.jar包,于是我把这个包加到工程中,同时在jsp开头包含进对应的类
<%@page import="org.gjt.xpp.*"%>
然后这错误也就不见了
jsp写完了,开开心心启动程序,一运行,结果又开始出现错误,还是一样的错误,想必刚刚是指标不治本。

查看异常说明,看到这样一句
Unable to compile class for JSP
怎么会不能编译呢,于是又百度,这次是说把工程下的servlet-api.jar和jsp.api.jar删除掉
我找了一下,我的工程只有servlet-api.jar,没有jsp.api.jar,我把servlet-api.jar删掉了,但是一删掉,工程中引用了这个包的类全都报错

显然这个方法行不通,于是我又把这个包添加回来。

上次写到一半,现在忘记具体细节了,只记得是要把servlet-api.jar放到工程的lib下,不能放在工程外面。应该是程序运行的时候,在lib下查找对应的类吧。

0 0