• Kaptcha验证码


     

    Kaptcha验证码

    1】:引包:kaptcha-2.3.2.jar(版本随意)

     

    2】:applictionContext.xml中的配置

    <!-- 验证码 -->

    <bean id="captchaProducer" class="com.google.code.kaptcha.impl.DefaultKaptcha">  

            <property name="config">  

                <bean class="com.google.code.kaptcha.util.Config">  

                    <constructor-arg>  

                        <props>  

                            <prop key="kaptcha.border">no</prop>  

                            <prop key="kaptcha.border.color">105,179,90</prop>  

                            <prop key="kaptcha.textproducer.font.color">red</prop>  

                            <prop key="kaptcha.image.width">250</prop>  

                            <prop key="kaptcha.textproducer.font.size">50</prop>  

                            <prop key="kaptcha.image.height">60</prop>  

                            <prop key="kaptcha.session.key">code</prop>  

                            <prop key="kaptcha.textproducer.char.length">4</prop>  

                            <prop key="kaptcha.textproducer.font.names">宋体,楷体,微软雅黑</prop>  

                        </props>  

                    </constructor-arg>  

                </bean>  

            </property>  

    </bean>

    3】:jsp中的配置

    1img

    <img title="看不清,点击刷新" style="float: right; height: 35px;"

           src="/captcha-image" width="150" height="54" id="kaptchaImage" onclick="changeImg()"/>  

    (2)changeImg()方法

    function changeImg(){

    $("#kaptchaImage").hide().attr("src", "/captcha-image?" + Math.floor(Math.random()*100) ).fadeIn();

    }

     

    Kaptcha验证码

    1】:引包:kaptcha-2.3.2.jar(版本随意)

     

    2】:applictionContext.xml中的配置

    <!-- 验证码 -->

    <bean id="captchaProducer" class="com.google.code.kaptcha.impl.DefaultKaptcha">  

            <property name="config">  

                <bean class="com.google.code.kaptcha.util.Config">  

                    <constructor-arg>  

                        <props>  

                            <prop key="kaptcha.border">no</prop>  

                            <prop key="kaptcha.border.color">105,179,90</prop>  

                            <prop key="kaptcha.textproducer.font.color">red</prop>  

                            <prop key="kaptcha.image.width">250</prop>  

                            <prop key="kaptcha.textproducer.font.size">50</prop>  

                            <prop key="kaptcha.image.height">60</prop>  

                            <prop key="kaptcha.session.key">code</prop>  

                            <prop key="kaptcha.textproducer.char.length">4</prop>  

                            <prop key="kaptcha.textproducer.font.names">宋体,楷体,微软雅黑</prop>  

                        </props>  

                    </constructor-arg>  

                </bean>  

            </property>  

    </bean>

     

     

    3】:jsp中的配置

    1img

    <img title="看不清,点击刷新" style="float: right; height: 35px;"

           src="/captcha-image" width="150" height="54" id="kaptchaImage" onclick="changeImg()"/>  

    (2)changeImg()方法

    function changeImg(){

    $("#kaptchaImage").hide().attr("src", "/captcha-image?" + Math.floor(Math.random()*100) ).fadeIn();

    }

     

     

     

  • 相关阅读:
    JPA的查询语言—使用构造器
    Servlet3.0使用注解定义Servlet
    jQuery操作<input type="radio">
    JPA的查询语言—使用原生SQL
    jQuery动态添加<input type="file">
    JPA的查询语言—JPQL的关联查询
    jQuery操作<select>
    Servlet3.0异步处理
    jQuery操作<input type="checkbox">
    mysql binlog二进制日志详解
  • 原文地址:https://www.cnblogs.com/ai211234/p/5620772.html
Copyright © 2020-2023  润新知