当前位置: 代码迷 >> Java Web开发 >> JSP页面中调用JavaBean时而运行成功,时而运行不成功.解决思路
  详细解决方案

JSP页面中调用JavaBean时而运行成功,时而运行不成功.解决思路

热度:68   发布时间:2016-04-17 13:45:35.0
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.daimami.com/search?q=2308
  相关解决方案