1、
加上html的编码语句
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
2、
String sbmemory = SBRs.getString("memory");
if (sbmemory.equals("forget"))//字符串不能使用==来比较
3、
<select name="year">
<option value=2001>2001
<option value=2002>2002
<option value=2003>2003
</select>
<select name="month">
<option value=1>1
<option value=2>2
<option value=3>3
.
.
.
</select>
<select name="date">
<option value=1>1
<option value=2>2
<option value=3>3
.
.
.
</select>
<script>
var y,m,d;
y=<%=new java.util.Date().getYear()%>;
m=<%=new java.util.Date().getMonth()%>+1;
d=<%=new java.util.Date().getDate()%>;
if(document.all.year.options[i]==y) {document.all.year.options[i].selected=true;}
if(document.all.month.options[i]==m) {document.all.year.options[i].selected=true;}
if(document.all.date.options[i]==d) {document.all.year.options[i].selected=true;}
</script>
加上html的编码语句
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
2、
String sbmemory = SBRs.getString("memory");
if (sbmemory.equals("forget"))//字符串不能使用==来比较
3、
<select name="year">
<option value=2001>2001
<option value=2002>2002
<option value=2003>2003
</select>
<select name="month">
<option value=1>1
<option value=2>2
<option value=3>3
.
.
.
</select>
<select name="date">
<option value=1>1
<option value=2>2
<option value=3>3
.
.
.
</select>
<script>
var y,m,d;
y=<%=new java.util.Date().getYear()%>;
m=<%=new java.util.Date().getMonth()%>+1;
d=<%=new java.util.Date().getDate()%>;
if(document.all.year.options[i]==y) {document.all.year.options[i].selected=true;}
if(document.all.month.options[i]==m) {document.all.year.options[i].selected=true;}
if(document.all.date.options[i]==d) {document.all.year.options[i].selected=true;}
</script>
解决方案 »
- 菜鸟的过滤器未能解决jsp中文乱码问题 求大侠帮忙
- 怎么得到传来的多个同名页面参数并缓存
- java使用FCKeditor上存路径问题
- request.setAttribute()后的页面显示问题
- 谁给我个jdbc驱动啊 在线等
- 谁有英文版的电子商务b2b或b2c原代码
- 100分!数据库连接数过多,怎样限制?在线等,急用!
- 如何控制单选按扭的集体显示或隐藏??
- 在red flag linux 下面配置jsp环境 需要哪几个步骤 我按照一些网站长的步骤配了,不行,急啊,大家帮帮忙。
- 请问:---?
- 救急!中文问题!!utf-8编码转成GBK,因为位数不同而产生字符丢掉问题!!
- 有个项目,哪位有兴趣的可以接手,
<%@page contentType = "text/html;charset=gb2312"%>
<%
String strqj = "请假";
%>
<%=strqj%>
2.equals()也没有问题
3.客户端部分,用js最好,下面以月为例
<form name=form1>
<select name=month>
<option value=1>1</option>
<option value=2>2</option>
<option value=3>3</option>
<option value=4>4</option>
<option value=5>5</option>
<option value=6>6</option>
<option value=7>7</option>
<option value=8>8</option>
<option value=9>9</option>
<option value=10>10</option>
<option value=11>11</option>
<option value=12>12</option>
</select>
</form>
<script>
var today=new Date();
var month=today.getMonth();
//alert(month);
form1.month.selectedIndex=month;
</script>
注意:getMonth()获得的月份比实际少1,getYear(),getDate()获得的与实际一样,另外select的下标selectedIndex是从0开始的
首先在页面最上方:<%@ page contentType="text/html; charset=gb2312" %>其次中文转化: if(str!=null&&!str.equals(""))
str= new String(str.getBytes("iso-8859-1"),"gb2312") ;
}
二。String比较问题:
利用equals()肯定不会出错;三。<%@ page contentType="text/html; charset=GBK" %>
<%@ page language="java"%>
<html>
<head>
<title></title>
<script language=JavaScript>
function checkform(form)
{
if(form.year.value==null||form.year.value=="")
{
alert("请输入您要查询的年份!");
return false;
}
else
{
var str=form.year.value;
var l=str.length;
if(l<4)
{
alert("您输入的年份不够四位!");
return false;
}
else
{
if(str.charAt(0)<"0"||str.charAt(0)>"9"||str.charAt(1)<"0"||str.charAt(1)>"9"||str.charAt(2)<"0"||str.charAt(2)>"9"||str.charAt(3)<"0"||str.charAt(3)>"9")
{
alert("您输入的年份中有非数字!");
return false;
}
else
{
return true;
}
}
}
}
</script>
<link href="images/css1.css" rel="stylesheet" type="text/css">
</head>
<%
java.util.Date today=new java.util.Date();
java.text.SimpleDateFormat format=new java.text.SimpleDateFormat("yyyyMMdd");
String todays=format.format(today);
String year=todays.substring(0,4);
String month=todays.substring(4,6);
String day=todays.substring(6,8);
%>
<body>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="80%">
<form name="form" method="POST" action="" >
<table width="50%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#000000">
<tr bgcolor="#FFFFFF">
<td width="25%" height="36" nowrap><font size="2"> 日 期:
</font></td>
<td nowrap> <font size="2">
<input type="text" name="year" value=<%=year%> size="4" maxlength="4">
<select size="1" name="month">
<option value="01" <%if(month.equals("01")){out.print(" selected");}%>>1月</option>
<option value="02" <%if(month.equals("02")){out.print(" selected");}%>>2月</option>
<option value="03" <%if(month.equals("03")){out.print(" selected");}%>>3月</option>
<option value="04" <%if(month.equals("04")){out.print(" selected");}%>>4月</option>
<option value="05" <%if(month.equals("05")){out.print(" selected");}%>>5月</option>
<option value="06" <%if(month.equals("06")){out.print(" selected");}%>>6月</option>
<option value="07" <%if(month.equals("07")){out.print(" selected");}%>>7月</option>
<option value="08" <%if(month.equals("08")){out.print(" selected");}%>>8月</option>
<option value="09" <%if(month.equals("09")){out.print(" selected");}%>>9月</option>
<option value="10" <%if(month.equals("10")){out.print(" selected");}%>>10月</option>
<option value="11" <%if(month.equals("11")){out.print(" selected");}%>>11月</option>
<option value="12" <%if(month.equals("12")){out.print(" selected");}%>>12月</option>
</select>
<select size="1" name="day">
<option value="01" <%if(day.equals("01")){ out.print(" selected");}%>>1日</option>
<option value="02" <%if(day.equals("02")){ out.print(" selected");}%>>2日</option>
<option value="03" <%if(day.equals("03")){ out.print(" selected");}%>>3日</option>
<option value="04" <%if(day.equals("04")){ out.print(" selected");}%>>4日</option>
<option value="05" <%if(day.equals("05")){ out.print(" selected");}%>>5日</option>
<option value="06" <%if(day.equals("06")){ out.print(" selected");}%>>6日</option>
<option value="07" <%if(day.equals("07")){ out.print(" selected");}%>>7日</option>
<option value="08" <%if(day.equals("08")){ out.print(" selected");}%>>8日</option>
<option value="09" <%if(day.equals("09")){ out.print(" selected");}%>>9日</option>
<option value="10" <%if(day.equals("10")){ out.print(" selected");}%>>10日</option>
<option value="11" <%if(day.equals("11")){ out.print(" selected");}%>>11日</option>
<option value="12" <%if(day.equals("12")){ out.print(" selected");}%>>12日</option>
<option value="13" <%if(day.equals("13")){ out.print(" selected");}%>>13日</option>
<option value="14" <%if(day.equals("14")){ out.print(" selected");}%>>14日</option>
<option value="15" <%if(day.equals("15")){ out.print(" selected");}%>>15日</option>
<option value="16" <%if(day.equals("16")){ out.print(" selected");}%>>16日</option>
<option value="17" <%if(day.equals("17")){ out.print(" selected");}%>>17日</option>
<option value="18" <%if(day.equals("18")){ out.print(" selected");}%>>18日</option>
<option value="19" <%if(day.equals("19")){ out.print(" selected");}%>>19日</option>
<option value="20" <%if(day.equals("20")){ out.print(" selected");}%>>20日</option>
<option value="21" <%if(day.equals("21")){ out.print(" selected");}%>>21日</option>
<option value="22" <%if(day.equals("22")){ out.print(" selected");}%>>22日</option>
<option value="23" <%if(day.equals("23")){ out.print(" selected");}%>>23日</option>
<option value="24" <%if(day.equals("24")){ out.print(" selected");}%>>24日</option>
<option value="25" <%if(day.equals("25")){ out.print(" selected");}%>>25日</option>
<option value="26" <%if(day.equals("26")){ out.print(" selected");}%>>26日</option>
<option value="27" <%if(day.equals("27")){ out.print(" selected");}%>>27日</option>
<option value="28" <%if(day.equals("28")){ out.print(" selected");}%>>28日</option>
<option value="29" <%if(day.equals("29")){ out.print(" selected");}%>>29日</option>
<option value="30" <%if(day.equals("30")){ out.print(" selected");}%>>30日</option>
<option value="31" <%if(day.equals("31")){ out.print(" selected");}%>>31日</option>
</select>
</font> <div align="center"></div></td>
</tr>
</table> <p> </p> <p align="center">
<input type="submit" name="submit" value="确 定">
<input type="reset" name="reset" value="重 置">
</p>
</form></td>
</tr>
<tr>
<td height="20%"> </td>
</tr>
</table>
</body>
</html>
改为:
<%@page contentType = "text/html;charset=ISO8859_1"%>
试试
int i,j,k;
java.util.Date d=new java.util.Date ();
String year1=String.valueOf (d.getYear()+1900);
String month1=String.valueOf (d.getMonth()+1);
String day1=String.valueOf (d.getDate());
if (month1.length()==1) month1="0"+month1;
if (day1.length()==1) day1="0"+day1;String[ ] subyear,submonth,subday;
subyear=new String[20];
submonth=new String[12];
subday=new String[31];
for (i=0;i<20;i++)
{
subyear[i]=String.valueOf(Integer.parseInt(year1)-10+i);
}
for (j=0;j<12;j++)
{
submonth[j]=String.valueOf(j+1);
}
for (k=0;k<31;k++)
{
subday[k]=String.valueOf(k+1);
}
%>
<select name="year1">
<%
for (i=0;i<20;i++)
{
if (subyear[i].equals(year1))
{
out.println("<option value="+year1+" selected >"+year1+"</span></option>");
}
else
{
out.println("<option value="+subyear[i]+">"+subyear[i]+"</option>");
}
}
%>
</select> <select name="month1">
<%
String monthstr;
for (i=0;i<12;i++)
{
if (submonth[i].length()==1)
{
monthstr="0"+submonth[i];
}
else
{
monthstr=submonth[i];
}
if (monthstr.equals(month1))
{
out.println("<option value="+monthstr+" selected >"+monthstr+"</option>");
}
else
{
out.println("<option value="+monthstr+">"+monthstr+"</option>");
}
}
%>
</select> <select name="day1">
<%
String daystr;
for (i=0;i<31;i++)
{
if (subday[i].length()==1)
{
daystr="0"+subday[i];
}
else
{
daystr=subday[i];
}
if (daystr.equals(day1))
{
out.println("<option value="+daystr+" selected >"+daystr+"</option>");
}
else
{
out.println("<option value="+daystr+">"+daystr+"</option>");
}
}
%>
</select>
你打上sp2的补丁包。tomcat的版本为4。0。4
我也遇到这样的问题的。不是你的代码的问题。