Chinaunix首页 | 论坛 | 博客
  • 博客访问: 524189
  • 博文数量: 151
  • 博客积分: 7010
  • 博客等级: 少将
  • 技术积分: 1405
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-22 14:32
文章分类

全部博文(151)

文章存档

2011年(1)

2010年(23)

2009年(1)

2008年(126)

我的朋友

分类: 系统运维

2008-08-08 11:45:49

一、Validating User Input Using JSTL Actions
    <%@ page contentType="text/html" %>
    <%@ taglib prefix="c" uri="" %>
     
   
     
        User Info Entry Form
     
     
     
       

         
         
           
             

             
           
           
             
             
           
           
             

             
           
           
             
             
             
           
           
             

             
           
           
             
             
             
           
             

             
           
           
             
             
           
           
             

             
           
           
             
             
             
           
           
             
               
                 
               

               
                 
               

               
                 
               

               
                 
               

             

           

           
             

             
           
           
             
             
           
           
             
           
         

                Please enter your Name
             
Name:
                                  value="">
             

                Please enter your Birth Date
             
Birth Date:
                                  value="">
             
(Use format yyyy-mm-dd)

                Please enter your Email Address
             
Email Address:
                                  value="">
             
(Use format >
           

                Please select a valid Gender
             
Gender:
               
                 
                   
                      Male

                   
                      Female
                 

                 
                   
                      Male

                   
                      Female
                 

               

             

                Please enter a Lucky Number between 1 and 100
             
Lucky number:
                                  value="">
             
(A number between 1 and 100)

                Please select only valid Favorite Foods
             
Favorite Foods:
                                  ${pizzaSelected ? 'checked' : ''}>Pizza

                                  ${pastaSelected ? 'checked' : ''}>Pasta

                                  ${chineseSelected ? 'checked' : ''}>Chinese
             

               
             

       

     
   

    The JSTL action is used with an EL expression that evaluates to true only if the condition is true .

二、Validating User Input Using a Bean
    ...
          class="com.ora.jsp.beans.userinfo.UserInfoBean">
     
   

   

     
     
                  test="${param.submitted && userInfo.userNameValid == false}">
         

         
       
       
         
         
       
       
         

         
       
       
         
         
         
       
       
         

         
       
       
         
         
       
       
         

         
       
       
         
         
       
        ...
阅读(802) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~

            Please enter your Name
         
Name:
                          value="">
         

            Please enter a valid Birth Date
         
Birth Date:
                          value="">
         
(Use format yyyy-mm-dd)

            Please select a valid Gender
         
Gender:
           
             
               
                  Male

               
                  Female
             

             
               
                  Male

               
                  Female
             

           

         

            Please select only valid Favorite Foods
         
Favorite Foods:
                          ${userInfo.pizzaSelected ? 'checked' : ''}>Pizza

                          ${userInfo.pastaSelected ? 'checked' : ''}>Pasta

                          ${userInfo.chineseSelected ? 'checked' : ''}>Chinese