You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.8 KiB
54 lines
1.8 KiB
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
<title>JSP计算器</title>
|
|
</head>
|
|
<body>
|
|
<jsp:useBean id="calcBean" class="jspSamples.unit5.javaBeanSamples.Calculater"></jsp:useBean>
|
|
<jsp:setProperty property="*" name="calcBean"/>
|
|
<%
|
|
calcBean.getResult();
|
|
%>
|
|
<hr>
|
|
计算结果是:
|
|
<jsp:getProperty property="num1" name="calcBean" />
|
|
<jsp:getProperty property="operator" name="calcBean" />
|
|
<jsp:getProperty property="num2" name="calcBean" />
|
|
=
|
|
<jsp:getProperty property="result" name="calcBean" />
|
|
<hr>
|
|
<form action="calculator.jsp" method="post">
|
|
<table style="text-align: center;">
|
|
<tr>
|
|
<td colspan="2">简单的计算器</td>
|
|
</tr>
|
|
<tr>
|
|
<td>第一个参数</td>
|
|
<td><input type="text" name="num1" /></td>
|
|
</tr>
|
|
<tr>
|
|
<td>操作符</td>
|
|
<td>
|
|
<select name="operator">
|
|
<option value="1">+</option>
|
|
<option value="2">-</option>
|
|
<option value="3">*</option>
|
|
<option value="4">/</option>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>第二个数</td>
|
|
<td><input type="text" name="num2" /></td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<button name="calc" type="submit">计算</button>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</form>
|
|
</body>
|
|
</html> |