zoukankan      html  css  js  c++  java
  • 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();

    }

     

     

     

  • 相关阅读:
    复利计算-做汉堡,结对2.0
    复利计算-结对
    《构建之法》第四章读后感
    复利计算单元测试
    实验一 命令解释程序的编写
    《构建之法》前三章章读后感
    1.0 2.0 3.0复利计算器
    实验0:了解和熟悉操作系统
    学习进度条
    0302思考并回答一些问题
  • 原文地址:https://www.cnblogs.com/ai211234/p/5620772.html
Copyright © 2011-2022 走看看