注册 登录
编程论坛 J2EE论坛

jsp页面加载bean出问题

rineshine 发布于 2011-10-13 22:14, 1197 次点击
---错误提示
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: /rectangle.jsp(3,35) quote symbol expected
    org.apache.(DefaultErrorHandler.java:41)
    org.apache.(ErrorDispatcher.java:407)
    org.apache.(ErrorDispatcher.java:88)
    org.apache.(Parser.java:222)
    org.apache.(Parser.java:162)
    org.apache.(Parser.java:153)
    org.apache.(Parser.java:953)
    org.apache.(Parser.java:1136)
    org.apache.(Parser.java:1449)
    org.apache.(Parser.java:138)
    org.apache.(ParserController.java:239)
    org.apache.(ParserController.java:102)
    org.apache.(Compiler.java:197)
    org.apache.(Compiler.java:372)
    org.apache.(Compiler.java:352)
    org.apache.(Compiler.java:339)
    org.apache.jasper.(JspCompilationContext.java:594)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:344)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


note The full stack trace of the root cause is available in the Apache Tomcat/7.0.11 logs.


--------------------------------------------------------------------------------

Apache Tomcat/7.0.11
----jsp文件:
<%@ page language="java" contentType="text/html; charset=gb2312"
    pageEncoding="gb2312"%>
<jsp:useBean id="rectangle" class=bean.Rectangle scope="page"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>javabean 的实例应用</title>
</head>
<body>
<%
    rectangle.setHeigh(4.5);
    rectangle.setWidth(5.0);
   
%>
<div align="center">
<h1> javabean 实例应用</h1>
<p>矩形的长是:<font color="#0000FF"><%=rectangle.getWidth() %></font></p>
<p>矩形的宽是:<font color ="0000FF"><%=rectangle.getHeigh() %></font>
</p>
<p>矩形的周长是:<font color="0000FF"><%=rectangle.getRectangleLength() %></font>
</p>
<p>矩形的面积是:<font color="0000FF"><%=rectangle.getRectangleArea() %></font>
</p>
</div>
</body>
</html>
------bean类
package bean;

public class Rectangle {
    private double width;
    private double height;
    private double rectangleLength;
    private double rectangleArea;
    public Rectangle(){
        this.width=0;
        this.height=0;
        this.rectangleArea=0;
        this.rectangleLength=0;
    }
    public void setWidth(double d){
        this.width=d;
    }
    public double getWidth(){
        return this.width;
    }
    public void setHeigh(double d){
        this.height=d;
    }
    public double getHeigh(){
        return this.height;
    }
    public double getRectangleLength(){
        this.rectangleLength=(this.height+this.width)*2;
        return this.rectangleLength;
    }
    public double getRectangleArea(){
        this.rectangleArea=this.height*this.width;
        return this.rectangleArea;
    }
   
}
4 回复
#2
gwl33234052011-10-14 10:07
不知道你什么错,检查rectangle.jsp第三行!是你JSP页面的错误。
#3
rineshine2011-10-14 12:50
jsp页面哪里的问题?请具体点
#4
wy1987122011-12-02 14:11
没家双引号吧,加上试试!
#5
zmp8002012-04-01 14:53
/rectangle.jsp(3,35) quote symbol expected 缺少引号的意思
<jsp:useBean id="rectangle" class=bean.Rectangle scope="page"/> ,class="....."你没加引号
1