100分!这个程序怎么了?晕
以下是bean.jsp的内容!!
<%@ page contentType= "text/html; charset=gb2312 " language= "java " %>
<head>
<title> 无标题文档 </title>
</head>
<jsp:useBean id= "personInfo " scope= "page " class= "Test.Person " />
<%personInfo.setName( "阿基米德 ");personInfo.setAge(55);%>
<body>
<h2 align= "center "> 显示javaBean中的信息 </h2>
<hr>
<%=personInfo.getName() %>
<%=personInfo.getAge() %>
</body>
</html>
以下是Person.java的内容!!
package Test;
public class Person
{
private String name=null;
private int age=-1;
public void setName(String name)
{
this.name = name;
}
public void setAge(int age)
{
this.age=age;
}
public String getName()
{
return name;
}
public int getAge()
{
return age;
}}
1.我Tomcat的文件路径:C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\myjsp\,其中myjsp是我的jsp文件存放处!
2.我在myjsp下建了一个classes的文件夹!
3.编译用的是javac -d . Person.java命令
4.然后把生成的Test(内含Person.class)放在classes下,运行bean.jsp,产生错误
把生成的Test(内含Person.java)放在myjsp下运行,也生关系到错误
把Person.java运行也不行!
5.错误都是以下这样的内容:
HTTP Status 500 -
--------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: /bean.jsp(5,0) The value for the useBean class attribute Test.Person 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:1175)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1117)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2164)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2214)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2220)
org.apache.jasper.compiler.Node$Root.accept(Node.java:457)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2164)
org.apache.jasper.compiler.Generator.generate(Generator.java:3322)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:199)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:296)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:299)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.23 logs.
[解决办法]
你的classes文件夹应该建在myjsp\WEB-INF文件夹下
[解决办法]
对,放置的路径不太对
[解决办法]
1 你的html代码不对称,只有 </html> 却忘了在开始加上 <html>
2 你的classes放置的位置不对,应该建在myjsp\WEB-INF文件夹下
3 你最好在myjsp\WEB-INF文件夹下建一个web.xml,里面的内容为
<web-app>
</web-app>
[解决办法]
应该是Bean的位置没放对,我以前遇到过这种情况,把Bean放在Tomcat根目录下的WEB-INF文件夹里的classes下就好了
[解决办法]
hehe
[解决办法]
帮顶
[解决办法]
顶,路径问题。
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html