三个parseInt需要加try{}catch(Exception e){}
Boolean 和boolean是不一样的附:不需要定义my_int,直接Integer.parseInt就可以的

解决方案 »

  1.   

    Integer my_int=new Integer(0); 
    int year=my_int.parseInt(stryear); 
    int month=my_int.parseInt(strmonth); 
    int day=my_int.parseInt(strday); 
    改成
    int year = Integer.parseInt(stryear);
    int month = Integer.parseInt(strmonth);
    int day = Integer.parseInt(strday);
      

  2.   

    <html>
    <head>
    <title>test</title>
    </head>
    <body>
    <% 
    String stryear=request.getParameter("year"); 
    String strmonth=request.getParameter("month"); 
    String strday=request.getParameter("day"); 
    Integer my_int=new Integer(0); 
    if (stryear==null) stryear="2004";
    if (strmonth==null) strmonth="4";
    if (strday==null) strday="18";
    int year=my_int.parseInt(stryear); 
    int month=my_int.parseInt(strmonth); 
    int day=my_int.parseInt(strday);
    boolean haserror=false;
     String errormsg=""; 
     if(year<1800||year>3000) 
     { haserror=true; 
    errormsg=" <li>error! year must be in 1800~2001!</li>"; 
    }
    if(month>12||month<1)
    {haserror=true;
    errormsg+=" <li>error! month must be in 1~12!</li>";
    }
    int maxDays=31;
    if(month==4||month==6||month==9||month==11)
    {maxDays=30;
    }
    else if(month==2)
    {if (year%4>0)
    {maxDays=28;
    }else if(year%100==0&&year%400>0)
    {maxDays=28;
    }else{
    maxDays=29;}
    }
    if(!(day>0&&day<=maxDays))
    {
    haserror=true;
    errormsg+="<li>error! there isn't "+day+ "days in this month!</li>";
    }
    if(haserror)
    {out.print("your input is "+year+"-"+month+"-"+day+"!");
    out.print("<br>");
    out.print(errormsg);
    }else{
    out.print("your birthday is "+year+"_"+month+"_"+day+"!");
    }
    %>
    </body>
    </html>
      

  3.   

    经过修改后,可以运行了:但有什么用?   
    your birthday is 2004_4_18!