问题:加载使用bean时,class=~后的包名和类名一直标红,错误提示为“无法解析包名或类名”
奉上源代码
JSP代码:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<% request.setCharacterEncoding("utf-8");%>
<jsp:useBean id="trapezoid" class="tom.jiafei.Trapezoid" scope="request"/>
<HTML><body bgcolor="#ffebcd">
<style>
#testStyle{
font-family: 宋体;font-size: 18px;color: black;text-align:center;
}
</style>
<p id="testStyle">
<form action="" method="post">
请输入梯形的各边<br>
上底:<input type="text" id="up"><br>
下底:<input type="text" id="down"/><br>
高:<input type="text" id="high"/><br>
<input type="submit" id="提交处理" size="12"/>
<jsp:setProperty name="trapezoid" property="up" param="up"/>
<jsp:setProperty name="trapezoid" property="down" param="down"/>
<jsp:setProperty name="trapezoid" property="high" param="high"/>
<br><b>梯形的各边:
<br><b>上底:<jsp:getProperty name="trapezoid" property="up"/>
<b>下底:<jsp:getProperty name="trapezoid" property="down"/>
<b>高:<jsp:getProperty name="trapezoid" property="high"/>
<br><b>梯形的面积:<jsp:getProperty name="trapezoid" property="area"/>
</form>
</p>
</body></HTML>
JAVA代码:
package tom.jiafei;
public class Trapezoid{
private double up;
private double down;
private double high;
private double area;
public double getUp(){
return up;
}
public double getDown(){
return down;
}
public double getHigh(){
return high;
}
public double getArea(){
area=(up+down)*high/2;
return area;}
public void setUp(double newup){
up=newup;
}
public void setDown(double newdown){
down=newdown;
}
public void setHigh(double newhigh) {
high = newhigh;
}
}