赞
踩
页面上显示1~3,3个链接,单击每个链接,能够在另一个页面打印该数字的平方。
4-1.jsp文件
- <%@ page contentType="text/html;charset=UTF-8" language="java" import="java.util.*"%>
-
- <%
- String path = request.getContextPath();
- String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
- %>
- <html>
- <head>
- <title>求平方</title>
- </head>
- <body>
- <p>点击计算下列数值的平方:</p>
- <a href="Square.jsp?n=12">12</a><br>
- <a href="Square.jsp?n=24">24</a><br>
- <a href="Square.jsp?n=36">36</a><br>
- </body>
- </html>
Square.jsp
- <%@ page contentType="text/html;charset=UTF-8" language="java" %>
- <html>
- <head>
- <title>求平方</title>
- </head>
- <body>
- <%
- String str=request.getParameter("n");
- int number=Integer.parseInt(str);
- %>
- 该数的平方为:<% out.println(number*number); %>
- </body>
- </html>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。