<%@page contentType="text/html" pageEncoding="GB2312"%>
<%@page import="java.text.*"%>
<%@taglib tagdir="/WEB-INF/tags" prefix="sx"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<FORM action="" method=get name=form>
<table>
<tr>
<td>请输入边长a</td>
<td><INPUT type="text" name="a"></td>
</tr>
<tr>
<td>请输入边长b</td>
<td><INPUT type="text" name="b"></td>
</tr>
<tr>
<td>请输入边长c</td>
<td><INPUT type="text" name="c"></td>
</tr>
</table>
<INPUT type="submit" value="提交" name=submit>
</form>
<%
String a=request.getParameter("a");
String b=request.getParameter("b");
String c=request.getParameter("c");
if(a==null||b==null||c==null){
a="0";
b="0";
c="0";
}
else if(a.length()>0&&b.length()>0&&c.length()>0){ %>
<sx:get_triangle_area sideA="<%= a%>"sideB="<%= b%>"sideC="<%= c%>"/>
<% }%>
<%
NumberFormat s=NumberFormat.getInstance();
s.setMaximumFractionDigits(6);//小数点后面6位
double result=areaA.doubleValue();
String str=s.format(result);
out.println(str);
%>
</body>
</html>
TAG:<%@tag description="put the tag description here" pageEncoding="GB2312"%>
<%-- The list of normal or fragment attributes can be specified here: --%>
<%@attribute name="sideC" required="true"%>
<%@attribute name="sideA" required="true"%>
<%@attribute name="sideB" required="true"%>
<%@variable name-given="areaA" variable-class="java.lang.Double" scope="AT_END" %>
<%-- any content can be specified here e.g.: --%>
<%
double a=Double.parseDouble(sideA);
double b=Double.parseDouble(sideB);
double c=Double.parseDouble(sideC);
if(a+b>c&&a+c>b&&b+c>a)
{
double p=(a+b+c)/2.0;
double result=Math.sqrt(p*(p-a)*(p-b)*(p-c));
jspContext.setAttribute("areaA",new Double(result));
}
else
jspContext.setAttribute("areaA", new Double(-1));
%>
variable指令为何无法将可以将Tag文件中的对象返回给调用该Tag文件的JSP页面如:areaA对象
问题:找不到错误: 找不到符号 double result=areaA.doubleValue();找不到areaA
答案:2 悬赏:30
解决时间 2021-03-22 22:09
- 提问者网友:清羽墨安
- 2021-03-22 06:42
最佳答案
- 二级知识专家网友:心与口不同
- 2021-03-22 07:39
void main()
{
double a,b,c,p,area;
printf("请输入3条边长:");
scanf("%d%d%d",&a,&b,&c); //逗号分隔,然后是 a b c如果为int类型%d,如果是double,则为 %lf
p=(a+b+c)/2;
area=sqrt(p*(p-a)*(p-b)*(p-c));
printf("area=%f/n",area);
}
{
double a,b,c,p,area;
printf("请输入3条边长:");
scanf("%d%d%d",&a,&b,&c); //逗号分隔,然后是 a b c如果为int类型%d,如果是double,则为 %lf
p=(a+b+c)/2;
area=sqrt(p*(p-a)*(p-b)*(p-c));
printf("area=%f/n",area);
}
全部回答
- 1楼网友:woshuo
- 2021-03-22 07:44
我。。知。。道
加。。我。。私。。聊
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯