恩 public hello() { System.out.println("Hello!"); }分明是个构造函数 怎么能这么用<% s.hello(); %>
不过你在bean中把构造函数改成 public void hello() { System.out.println("Hello!"); }
你的jsp也可以通过。
哦,好像不是这个原因 我换成 public void test() { System.out.println("Hello!"); } public hello(){}然后s.test()也是同样的错误...
总之似乎不是构造函数的问题 错误里有这么一句 class file contains wrong class: hello Please remove or make sure it appears in the correct subdirectory of the classpath. beans.hello s = null;不知道暗示了什么?
C:\tools\Tomcat 5.0\work\Catalina\localhost\myapp\org\apache\jsp\_1_jsp.java:42: cannot access beans.helloAn error occurred at line: 9 in the jsp file: /1.jspGenerated servlet error: bad class file: D:\work\programme\JSP\WEB-INF\classes\beans\hello.class class file contains wrong class: hello Please remove or make sure it appears in the correct subdirectory of the classpath. beans.hello s = null; ^ 1 error 路径挺怪的
hello.class放在Tomcat/classes/beans/ 下,試試看。
public hello() { System.out.println("Hello!"); } 这是构造函数 不是方法 public void hel() { System.out.println("Hello!"); }s.hel()
就是楼主在jsp中调用了构造方法的原因,后来还是出错应该是你改了类却没改jsp引起的。
这样写public class Hello { public Hello() { //System.out.println("Hello!"); } public void test(){ System.out.println("Hello!"); }
{
System.out.println("Hello!");
}分明是个构造函数 怎么能这么用<%
s.hello();
%>
public void hello()
{
System.out.println("Hello!");
}
你的jsp也可以通过。
我换成
public void test()
{
System.out.println("Hello!");
}
public hello(){}然后s.test()也是同样的错误...
错误里有这么一句
class file contains wrong class: hello
Please remove or make sure it appears in the correct subdirectory of the classpath.
beans.hello s = null;不知道暗示了什么?
http://community.csdn.net/Expert/topic/3718/3718003.xml?temp=.3047296
http://community.csdn.net/Expert/topic/3714/3714604.xml?temp=.3814508我都有回答
{
public hello(){}
public void hello1()
{
System.out.println("hello");
}
}s.hello1();
提醒一下 在jsp页面里,输出要用out.println("Hello,welcome to java");
System.out.println("Hello!");只能在控制台下看到(不过不会报错)
搂主的问题:
cannot access beans.hello:说明无法访问该文件,
呵呵,这个是Windows文件访问权限的问题
在beans文件夹上点击右键->选择"安全"-〉查看里面各个用户的权限,添加上合适的权限
最好是为该文件夹添加everyone用户,这样,所有人都可以访问这个文件夹了,你的问题
也就解决了, 还有问题的话就是RPWT啦,到时候我再看看
bad class file: D:\work\programme\JSP\WEB-INF\classes\beans\hello.class
class file contains wrong class: hello
Please remove or make sure it appears in the correct subdirectory of the classpath.
beans.hello s = null;
^
1 error
路径挺怪的
{
System.out.println("Hello!");
}
这是构造函数 不是方法
public void hel()
{
System.out.println("Hello!");
}s.hel()
{
public Hello()
{
//System.out.println("Hello!");
}
public void test(){
System.out.println("Hello!");
}
}jsp文件里面s.test();
构造函数是不能被调用的,不过一个例外是构造函数调用构造函数,通过this.
public good(){ this.(10); }public good(int s){System.out.println(s);}
}
public class hello
{
public hello()
{
System.out.println("Hello!");
}
}你的Bean这样写本来就是错误的,Bean是不用构造函数的。
我重起了机器,突然就可以了,晕!