我是个菜鸟 按书上做的例子 出现这个错误 问下高手 JSP文件放那个目录下 CLASS 文件放那个目录下???我把JAVABEAN 那些删除掉 就不出错 真郁闷啊我的 jsp文件 <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<jsp:useBean id="count" scope="session" class="chapter2.Counter"/>
<%
out.println("aaaaaaaaa"+count.getCount()+<BR>);
%>asdasdasdasdasdasdasd
<jsp:getProperty name="count" property="count"/><BR>
</body>
</html>
我的 java文件 是不是 用eclipse 保存 然后直接去bin目录下 拷贝那个 。class 就行????package lesson;
public class Counter {
Counter(){
}
int count = 0;
public int getCount() {
count++;
return count;
}
public void setCount(int count) {
this.count = count;
}
}我用的 tomcat6.0.14 11.jsp 放在 F:\apache-tomcat-6.0.14\webapps\ROOT class文件 放在 F:\apache-tomcat-6.0.14\webapps\ROOT\WEB-INF\classes\chapter2 我运行 http://localhost:8080/11.jsp 就出着错 郁闷了
Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: /11.jsp(10,0) The value for the useBean class attribute chapter2.Counter is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1200)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1155)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2338)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2388)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2394)
org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2338)
org.apache.jasper.compiler.Generator.generate(Generator.java:3374)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:210)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:306)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.14 logs.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<jsp:useBean id="count" scope="session" class="chapter2.Counter"/>
<%
out.println("aaaaaaaaa"+count.getCount()+<BR>);
%>asdasdasdasdasdasdasd
<jsp:getProperty name="count" property="count"/><BR>
</body>
</html>
我的 java文件 是不是 用eclipse 保存 然后直接去bin目录下 拷贝那个 。class 就行????package lesson;
public class Counter {
Counter(){
}
int count = 0;
public int getCount() {
count++;
return count;
}
public void setCount(int count) {
this.count = count;
}
}我用的 tomcat6.0.14 11.jsp 放在 F:\apache-tomcat-6.0.14\webapps\ROOT class文件 放在 F:\apache-tomcat-6.0.14\webapps\ROOT\WEB-INF\classes\chapter2 我运行 http://localhost:8080/11.jsp 就出着错 郁闷了
Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: /11.jsp(10,0) The value for the useBean class attribute chapter2.Counter is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1200)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1155)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2338)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2388)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2394)
org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2338)
org.apache.jasper.compiler.Generator.generate(Generator.java:3374)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:210)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:306)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.14 logs.
把chapter2改为lesson试一下,然后在javabean中改为lesson.Counter,这样应该行的!
顶!!
<%@ page language="java" import="类路径" %>
.class文件放在的目录 WEB-INF\classes\XXX\Counter.class
页面中的useBean标签 class="XXX.Counter"
这三个要一致,改哪些个无所谓
翻译成中文是:这个值在chapter2.Counter 类中是无效的。
在找找吧