当前位置: 技术问答>java相关
javabean+jsp出错
来源: 互联网 发布时间:2015-10-17
本文导语: javabean+jsp出错,我把*.class放在D:TomcatwebappsexamplesWEB-INFclasses下,把*.jsp放在D:Tomcatwebappsexamplesjsp下.代码是抄书的,应该没错.环境变量也设了. 主要错误提示如下: type exception report message description The server encountered an...
javabean+jsp出错,我把*.class放在D:TomcatwebappsexamplesWEB-INFclasses下,把*.jsp放在D:Tomcatwebappsexamplesjsp下.代码是抄书的,应该没错.环境变量也设了.
主要错误提示如下:
type exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
An error occurred at line: 2 in the jsp file: /jsp/TestBean.jsp
Generated servlet error:
D:TomcatworkStandalonelocalhostexamplesjspTestBean_jsp.java:45: cannot resolve symbol
symbol : class TestBean
location: class org.apache.jsp.TestBean_jsp
MyFirstBean = (TestBean) pageContext.getAttribute("MyFirstBean", PageContext.PAGE_SCOPE);
^
An error occurred at line: 2 in the jsp file: /jsp/TestBean.jsp
Generated servlet error:
D:TomcatworkStandalonelocalhostexamplesjspTestBean_jsp.java:48: cannot resolve symbol
symbol : class TestBean
location: class org.apache.jsp.TestBean_jsp
MyFirstBean = (TestBean) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "TestBean");
^
An error occurred at line: 3 in the jsp file: /jsp/TestBean.jsp
Generated servlet error:
D:TomcatworkStandalonelocalhostexamplesjspTestBean_jsp.java:59: cannot resolve symbol
symbol : variable MyBean
location: class org.apache.jsp.TestBean_jsp
out.println("javaBean"+MyBean.getName()+"");
^
4 errors
主要错误提示如下:
type exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
An error occurred at line: 2 in the jsp file: /jsp/TestBean.jsp
Generated servlet error:
D:TomcatworkStandalonelocalhostexamplesjspTestBean_jsp.java:45: cannot resolve symbol
symbol : class TestBean
location: class org.apache.jsp.TestBean_jsp
MyFirstBean = (TestBean) pageContext.getAttribute("MyFirstBean", PageContext.PAGE_SCOPE);
^
An error occurred at line: 2 in the jsp file: /jsp/TestBean.jsp
Generated servlet error:
D:TomcatworkStandalonelocalhostexamplesjspTestBean_jsp.java:48: cannot resolve symbol
symbol : class TestBean
location: class org.apache.jsp.TestBean_jsp
MyFirstBean = (TestBean) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "TestBean");
^
An error occurred at line: 3 in the jsp file: /jsp/TestBean.jsp
Generated servlet error:
D:TomcatworkStandalonelocalhostexamplesjspTestBean_jsp.java:59: cannot resolve symbol
symbol : variable MyBean
location: class org.apache.jsp.TestBean_jsp
out.println("javaBean"+MyBean.getName()+"");
^
4 errors
|
感觉还是代码的问题,你把代码全铁出来吧。不然没办法帮你
|
按照错误提示前面三个应该是指找不到TestBean这个class,后面是比较明显的变量名字错误MyBean应该是MyFirstBean。
但我今天在weblogic6.1下测试时,发现个奇怪的问题,就是不给JavaBean加包名就提示找不到JavaBean,加包名后就正确了。当然,加包名就要相应地改变JavaBean所存放的位置。
TestBean.jsp代码如下:
TestBean.java代码如下:
package com.test;
public class TestBean{
String Name="awei";
public TestBean(){
}
public String getName(){
return this.Name;
}
public void setName(String value){
this.Name=value;
}
}
但我今天在weblogic6.1下测试时,发现个奇怪的问题,就是不给JavaBean加包名就提示找不到JavaBean,加包名后就正确了。当然,加包名就要相应地改变JavaBean所存放的位置。
TestBean.jsp代码如下:
TestBean.java代码如下:
package com.test;
public class TestBean{
String Name="awei";
public TestBean(){
}
public String getName(){
return this.Name;
}
public void setName(String value){
this.Name=value;
}
}