org.apache.jasper.JasperException: Unable to load class for JSP

来源:百度知道 编辑:UC知道 时间:2024/05/29 22:57:40
初学jsp,碰上javabean就出问题了。
源程序:
<%@ page contentType = "text/html;charset=GB2312" %>
<jsp:useBean id = "rectangle" class = "com/chapter2/Rectangle" scope = "page" />
<html>
<head>
<title>javaBean应用实例</title>
</head>
<body>
<%
rectangle.setWidth(4.5);
rectangle.setHeight(2.0);
%>
<div align = "center">
<h1>JavaBean应用实例</h1>
<font size = "4" >
<P>矩形的长度是:<%=rectangle.getWidth()%></P>
<P>矩形的高度是:<%=rectangle.getHeight()%></P>
<P>矩形的周长是:<%=rectangle.getRectangleLength()%></P>
<P>矩形的面积是:<%=rectangle.getRectangleArea()%></P>
</font>
</div>
</body>
</html>

Rectangle类放在D:\JSP\chapter2\com\chapter2\

<jsp:useBean id = "rectangle" class = "com/chapter2/Rectangle" scope = "page" />

语法不对啊改成:

<jsp:useBean id = "rectangle" class = "com.chapter2.Rectangle" scope = "page" />

chapter2类文件应该放在你的WEB程序的WEB_INF/classes/com/chapter2/ 下面

没有这个路径的话 新建一个

总之,你抄书也没抄对吧/?

给个建议:书看的少!

在服务器里你如何发布的呢?路径如何?