你的位置:首页 > 软件开发 > Java > Servlet简单计算器 2.0

Servlet简单计算器 2.0

发布时间:2016-07-05 09:00:08
jsp 输入界面: 1 <%@ page language="java" contentType="text/html; charset=UTF-8" 2 pageEncoding="UTF-8"%> 3 ...

Servlet简单计算器 2.0

jsp 输入界面:

 1 <%@ page language="java" contentType="text/html; charset=UTF-8" 2   pageEncoding="UTF-8"%> 3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 4 <html> 5 <head> 6 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 7 <title>Servlet计算器</title> 8 </head> 9 <body bgcolor="#afb4db">10 <%11 String s1 = "";12 Object ob = session.getAttribute("jg");13 if(ob != null){14   s1 = ob.toString();15 }16 session.invalidate();17 %>18 <form action="TestJSQ" method="post">19 <table border="1" align="center">20  <tr align="center"><td colspan="4">简易计算器</td></tr>21  <tr>22    <td colspan="4"><textarea name="text" id="tt" cols="22" rows="1"><%= s1 %></textarea></td></tr>23  <tr align="center">24    <td width="40" align="center"><input type="reset" value="C" style="width: 40px;"></td> 25    <td width="40"><input type="button" value="off" onclick="doselect(this)"></td>26    <td width="40"><input type="button" value="+" onclick="doselect(this)" style="width: 40px;"></td>27    <td width="40"><input type="button" value="←" onclick="doselect(this)" style="width: 40px;"></td></tr> 28  <tr align="center">29    <td><input type="button" value="7" onclick="doselect(this)"></td> 30    <td><input type="button" value="8" onclick="doselect(this)"></td>31    <td><input type="button" value="9" onclick="doselect(this)"></td>32    <td><input type="button" value="-" onclick="doselect(this)" style="width: 40px;"></td></tr> 33  <tr align="center">34    <td><input type="button" value="4" onclick="doselect(this)"></td> 35    <td><input type="button" value="5" onclick="doselect(this)"></td>36    <td><input type="button" value="6" onclick="doselect(this)"></td>37    <td><input type="button" value="x" onclick="doselect(this)" style="width: 40px;"></td></tr>38  <tr align="center">39    <td><input type="button" value="1" onclick="doselect(this)"></td> 40    <td><input type="button" value="2" onclick="doselect(this)"></td>41    <td><input type="button" value="3" onclick="doselect(this)"></td>42    <td><input type="button" value="/" onclick="doselect(this)" style="width: 40px;"></td></tr>43  <tr align="center">44    <td><input type="button" value="." onclick="doselect(this)"></td> 45    <td><input type="button" value="0" onclick="doselect(this)"></td>46    <td><input type="submit" value="=" onclick="doselect(this)"></td>47    <td><input type="button" value="%" onclick="doselect(this)" style="width: 40px;"></td></tr>48  <tr align="center"><td colspan="4">说明:除数为0时,结果=<br>-9.99999999E8即表示报错</td></tr> 49 </table>50 </form>51 <%52 53 %>54 </body>55 </html>56 <script language="javascript">57 58 function doselect(bt){ 59  var obj = document.getElementById('tt'); 60  var s = bt.value;61   obj.innerHTML += s;62  if(s == "←"){63    var a = obj.value;64     s = a.substring(0, a.length-2);65     obj.innerHTML = s; 66   }67  if(s == "off"){68     window.close();69   }70 }71 </script>

 

海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com

原标题:Servlet简单计算器 2.0

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

可能感兴趣文章

我的浏览记录