
如何用java循环下拉框当年年份的前4年后1年 跪求!
2个回答
2010-01-21
展开全部
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
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 '1.jsp' starting page</title>
</head>
<body>
<select name="year">
<%
Calendar c=Calendar.getInstance();
int now=c.get(Calendar.YEAR);
now-=3;
for(int i=0;i<5;i++){
out.println("<option value="+now+">"+now+"</option>");
now++;
}
%>
</select>
</body>
</html>
<%
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 '1.jsp' starting page</title>
</head>
<body>
<select name="year">
<%
Calendar c=Calendar.getInstance();
int now=c.get(Calendar.YEAR);
now-=3;
for(int i=0;i<5;i++){
out.println("<option value="+now+">"+now+"</option>");
now++;
}
%>
</select>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询