初学jsp+javabean时的有关问题 找不到class
初学jsp+javabean时的问题 找不到class
我的一个JSP+Javabean的练习放在如下路径
D:\J2ee\Apache Software Foundation\Tomcat 6.0\webapps\Jsp\exercises
useBean -folder 下面
-[WEB-INF] ---> Folder
-classes ----> folder
- tax ----> folder
-TaxRate.class
- TaxRate.java
-UseBean.jsp
-settax.jsp
UseBean.jsp
-----------------
settax.jsp
-----------------------
TaxRate.java
------------------
..\Tomact6.0\conf\Server.xml 中<host 部分的缺省如下
在ie 中进入以下页面 并输入 产品: test , 税率: 17.0
http://localhost:8080/Jsp/exercises/useBean/settax.jsp
提交后error message 如下:
org.apache.jasper.JasperException: /exercises/useBean/UseBean.jsp(4,0) The value for the useBean class attribute tax.TaxRate is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
我的一个JSP+Javabean的练习放在如下路径
D:\J2ee\Apache Software Foundation\Tomcat 6.0\webapps\Jsp\exercises
useBean -folder 下面
-[WEB-INF] ---> Folder
-classes ----> folder
- tax ----> folder
-TaxRate.class
- TaxRate.java
-UseBean.jsp
-settax.jsp
UseBean.jsp
-----------------
- HTML code
<html> <body> <%@ page language="java" %> <jsp:useBean id="taxbean" scope="application" class="tax.TaxRate" /> <jsp:setProperty name="taxbean" property="*"/> 产品:<jsp:getProperty name="taxbean" property="product"/> <br> 税率:<jsp:getProperty name="taxbean" property="rate"/> </body> </html>
settax.jsp
-----------------------
- HTML code
<html> <head> <title>设置产品税率</title> </head> <body bgcolor="#fffffr"> <FORM method="post" action="UseBean.jsp"> <TABLE border=0 cellspacing=1 cellpadding=5> <TR> <td width="100"> </td> <td align="right"><H1><FONT color="red">设置产品税率</FONT></H1></TD> </TR> <TR> <td width="100" align="right"><B><FONT color="blue">产品:</FONT></B></TD> <td align="left"><INPUT TYPE="text" name="product" size="30"></TD> </TR> <TR> <td width="100" align="right"><B><FONT color="blue">税率:</FONT></B></TD> <td align="left"><INPUT TYPE="text" name="rate" size="30"></TD> </TR> <TR> <td width="100"> </TD> <td align="right"></TD> </TR> <TR> <TD width="100"> </td> <td align="left"><input type="submit" value="Submit"></td> </tr> </table> </FORM> </BODY> </HTML>
TaxRate.java
------------------
- Java code
package tax; public class TaxRate { double rate; String product; public TaxRate(){ } public void setProduct(String ProductName){ this.product=ProductName; } public String getProduct(){ return (this.product); } public void setRate(double rateValue){ this.rate=rateValue; } public double getRate(){ return this.rate;} }
..\Tomact6.0\conf\Server.xml 中<host 部分的缺省如下
- XML code
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
在ie 中进入以下页面 并输入 产品: test , 税率: 17.0
http://localhost:8080/Jsp/exercises/useBean/settax.jsp
提交后error message 如下:
org.apache.jasper.JasperException: /exercises/useBean/UseBean.jsp(4,0) The value for the useBean class attribute tax.TaxRate is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)