counter.javapublic class counter {
int count = 0;
public counter() {}
public int getcount() {
count++;
return this.count;}
public void setcount(int count) {
this.count = count;}} counter.jsp:<html><body>
<jsp:usebean id="bean0" scope="application" class="counter"/>
the counter is :
<jsp:getproperty name="bean0" property="count" /><br>
</body></html> counter.class 放在root\web-inf\classes\counter.class
counter.jsp 放在webapps\Myapp\counter.jsp
为啥不对呢?counter.jsp 页面错误?
int count = 0;
public counter() {}
public int getcount() {
count++;
return this.count;}
public void setcount(int count) {
this.count = count;}} counter.jsp:<html><body>
<jsp:usebean id="bean0" scope="application" class="counter"/>
the counter is :
<jsp:getproperty name="bean0" property="count" /><br>
</body></html> counter.class 放在root\web-inf\classes\counter.class
counter.jsp 放在webapps\Myapp\counter.jsp
为啥不对呢?counter.jsp 页面错误?
public class counter {
int count = 0;
public counter() {}
public int getCount(){
count++;
return this.count;
}
public void setCount(int count) {
this.count = count;
}
}
改为
getProperty
改为
useBean
<%@ page contentType="text/html; charset=UTF-8"%>
将 counter.java 放在aa这个包下。
counter.java 代码如下:package aa;public class counter {
int count = 0;
public counter() {}
public int getcount() {
count++;
return this.count;}
public void setcount(int count) {
this.count = count;}}
counter.jsp:代码如下:
<html>
<body>
<jsp:useBean id="bean0" scope="application" class="aa.counter"/>the counter is :
<jsp:getProperty name="bean0" property="count" /> <br>
</body>
</html>
counter.class 放在root\web-inf\classes\aa\counter.class
counter.jsp 放在webapps\Myapp\counter.jsp 这样就可以了。已经调试过了。
没刷新一次就会加一。
org.apache.jasper.JasperException: /counter.jsp(3,1) The value for the useBean class attribute aa.counter is invalid.
你的counter里面压根儿没有counter 这个属性,当然保存啦,在counter 中定义counter 这个属性
The value for the useBean class attribute aa.counter is invalid.
package aa; public class counter {
int count = 0;
public counter() {}
public int getcount() {
count++;
return this.count;}
public void setcount(int count) {
this.count = count;}}
<html>
<body>
<jsp:useBean id="bean0" scope="application" class="aa.counter"/>
the counter is :
<jsp:getProperty name="bean0" property="count" /> <br>
</body>
</html>
org.apache.jasper.JasperException: /counter.jsp(3,1) The value for the useBean class attribute aa.counter is invalid.是counter.jsp 中在第三行的代码中 的属性出现错误。
就是
<jsp:usebean id="bean0" scope="application" class="counter"/>
改为
<jsp:useBean id="bean0" scope="application" class="aa.counter"/>
The value for the useBean class attribute aa.counter is invalid.
???????????????????????????????
????????????????????????????????
谢谢!
counter.jsp 放在webapps\Myapp\counter.jsp 修改为
counter.class 放在webapps\Myapp\web-inf\classes\aa\counter.class
counter.jsp 放在webapps\Myapp\counter.jsp 这样你的错误就可以消失了。至于环境变量在百度上随便一搜就可以搜到了。
配完环境变量以后再
cmd里面输入 javac
没有错误就证明你的环境变量配置成功了。
楼主在生成get()和set()方法是用快捷键自动生成不要手写
就是,在前面引用一下aa这个包,然后再写class="counter"
private int count = 0;
public counter() {}
public int getcount() {
count++;
return this.count;}
public void setcount(int count) {
this.count = count;}} counter.jsp: <html> <body>
<jsp:useBean id="bean0" scope="application" class="counter"/>
the counter is :
<jsp:getProperty name="bean0" property="count" /> <br>
</body> </html>
count++;
return this.count;}
public void setCount(int count) {
this.count = count;}}
我感觉还是路径有问题,我贴出来大家看看,一定要帮我:
D:
|
Program Flies
|
Apache Software Foundation
|
Tomcat 6.0
|
webapps
|
ROOT myapps ------在webapps目录下新建myapps,放置作业文件counter.jsp
| |
WEB-INF counter.jsp
|
classes -----WEB-INF目录下原来没有classes目录,新建classes目录,放置
| aa.counter.class文件,同时在操作系统环境变量中新增系统变量
aa classpath=D:\Program Files\Apache Software Foundation\Tomcat 6.0
| \webapps\ROOT\WEB-INF\classes
counter.class