JSP页面中调用JavaBean时而运行成功,时而运行不成功.
很简单的bean测试
-----------------------------------
(TestBean.java)
package test;
public class TestBean {
public int getTest(){
return 34;
}
}
(test.jsp)
<%@ page contentType= "text/html; charset=gb2312 "
errorPage= "/errorpage.jsp " %>
<%@ page import= "test.TestBean " %>
<%
TestBean tb=new TestBean();
out.println(tb.getTest());
%>
-------------------------------
出现如下错误:
org.apache.jasper.JasperException: Unable to compile class for JSP
Generated servlet error:
Only a type can be imported. test.TestBean resolves to a package
An error occurred at line: 3 in the jsp file: /test.jsp
Generated servlet error:
TestBean cannot be resolved to a type
An error occurred at line: 3 in the jsp file: /test.jsp
Generated servlet error:
TestBean cannot be resolved to a type
-----------------------------------
奇怪的是这样的错误有时候出现,有时候不出现(运行成功),PS:对程序和配置没有做任何的改变
-----------------------------------
我的系统配置为:Tomcat 5.5+jdk1.5.0_07+Eclipse3.2+GhostXP_SP2电脑公司特别版版本:6.0
------解决方案--------------------> Only a type can be imported. test.TestBean
resolves to a package import错误
我的异常网推荐解决方案:org.apache.jasper.JasperException: Unable to compile class,http://www.aiyiweb.com/j2ee/2308.html