jsp:useBean javabean
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><%@ page import="com.zn.Entity.Triangle"%>
<jsp:useBean id="易做图" class="com.zn.Entity.Triangle" scope="page" />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'Triangle.jsp' starting page</title>
</head>
<body>
<FORM Method="post" class="com.zn.Entity.Triangle" id="易做图">
<P>
输入三角形三边: <BR>
边A:<Input type=text name="sideA" value=0>
边B:<Input type=text name="sideB" value=0>
边C:<Input type=text name="sideC" value=0> <br>
<Input type=submit value="提交">
</FORM>
<jsp:setProperty name="易做图" property="*" />
<P>
三角形的三边是: <BR>
边A:<jsp:getProperty name="易做图" property="sideA" />
边B:<jsp:getProperty name="易做图" property="sideB" />
边C:<jsp:getProperty name="易做图" property="sideC" />
<P>
这三个边能构成一个三角形吗?
<jsp:getProperty name="易做图" property="易做图" />
<P>
面积是:
<jsp:getProperty name="易做图" property="area" />
</body>
</html>
package com.zn.Entity;
public class Triangle {
double sideA=-1,
sideB=-1,
sideC=-1,
area=-1;
boolean 易做图;
public Triangle() {
super();
}
public Triangle(double sideA, double sideB, double sideC) {
super();
this.sideA = sideA;
this.sideB = sideB;
this.sideC = sideC;
}
public double getSideA() {
return sideA;
}
public void setSideA(double sideA) {
this.sideA = sideA;
}
public double getSideB() {
return sideB;
}
public void setSideB(double sideB) {
this.sideB = sideB;
}
public double getSideC() {
return sideC;
}
public void setSideC(double sideC) {
this.sideC = sideC;
}
// 是否是三角形
public boolean isTriangle()
{
if (sideA < sideB + sideC && sideB < sideA + sideC
&& sideC < sideA + sideB)
易做图 = true;
else
易做图 = false;
return 易做图;
}
public double getArea()
{ double p=(sideA+sideB+sideC)/2.0;
if(易做图)
area=Math.sqrt(p*(p-sideA)*(p-sideB)*(p-sideC));
return area;
}
}
javabean jsp:useBean --------------------编程问答-------------------- 你想表达什么意思?? --------------------编程问答-------------------- 发错了,本来想给别人回帖的。
补充:Java , Web 开发