`
chaoyi
  • 浏览: 291297 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

Jsp查找闰年

 
阅读更多
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>  
    <title>查找闰年</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">
	
  </head>  
  <body>
    <%!
    	boolean findYear(int year){
    		if(((year%4==0)&&(year%100!=0)) || year%400==0){
    			return true;
    		}else{
    			return false;
    		}
    	}
     %>
     
     <%
     	int count = 0;
     	StringBuffer sb = new StringBuffer();
     	for(int i=2000; i<=2010; i++){
     		if(findYear(i)){
     		count++;
     		sb.append(i).append("&nbsp;&nbsp;");
     		}
     	}
      %>
      从2000年到2010年期间,共有<%=count %>个闰年,分别是<%=sb.toString() %>
  </body>
</html>

 

效果图:

 

  • 大小: 12.7 KB
1
1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics