不要急,我与你一起学习JSP(一)――平台搭建,让你眼前一亮
2014-08-12 13:55
323 查看
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <%@page import="com.deng.testjs.model.Person"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'index.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> <script type="text/javascript"> /** 利用递归实现: 1 1 2 3 5 8 13 21 34 根据规律(从第3项开始后项等于前面两项之和),请第30项的值 */ function test(){ alert("非递归值为=" + cal(9)); alert("递归值为=" + calcForRecursive(9)); } /** 不用递归实现 */ function cal(number){ if(number <= 2){ return 1; } var a1 = 1; var a2 = 1; var result; var temp; for(var i = 2; i < number; i++){ result = a1 + a2; temp = a2; a2 = result; a1 = temp; } return result; } function calcForRecursive(number){ if(number <= 2){ return 1; } return recursiveHandler(1, 1, 2,number); } function recursiveHandler(a1,a2,count,number){ var result = a1 + a2; count++; if(count == number){ return result; }else{ return recursiveHandler(a2,result,count,number); } } </script> </head> <body> This is my JSP page. <br> <input type="button" onclick="test()" value="test"> </body> </html>
相关文章推荐
- 不要急,我与你一起学习JSP(一)——平台搭建,让你眼前一亮
- 我与你一起学习JSP(一)——平台搭建,让你眼前一亮
- 不要急,我与你一起学习JSP
- 不要急,我与你一起学习JSP(五)——JSP 目录结构简介
- 不要急,我与你一起学习JSP(二)――JSP的基本概述
- 不要急,我与你一起学习JSP(六)——JSP 内置对象之一
- 不要急,我与你一起学习JSP(四)――JSP的基础语法【二】
- 不要急,我与你一起学习JSP(四)——JSP的基础语法【二】
- 不要急,我与你一起学习JSP(三)――JSP的基础语法【一】
- 不要急,我与你一起学习JSP(三)——JSP的基础语法【一】
- 不要急,我与你一起学习JSP(二)——JSP的基本概述
- AS3-学习笔记-flashdevelop平台-搭建-配置(转载加补充)
- 搭建一个学习交流的平台,希望大家热心参与
- python学习——python平台搭建
- AS3-学习笔记-flashdevelop平台-搭建-配置
- 用lomboz(Object Web)搭建一个JSP(JAVA WEB)开发平台
- Extjs+Struts+simpleCaptcha+jsp:搭建你的验证码平台
- 一步一步跟我学Linux平台下搭建Jsp状况-1
- 一起学习MVC(3)-搭建项目
- 一步一步跟我学Linux平台下搭建Jsp景象-2