struts2 CAPTCHA图像插件

来源:互联网 发布:乐视手机网络时间同步 编辑:程序博客网 时间:2024/04/30 06:35

CAPTCHA(Completely Automated Public Turning Test to tell Computers and Humans Apart)部件。下载地址

使用方法:

在Package中注册Result-type,在action中加入以下代码:

<result type="captcha"><param name="hashCookieName">hashCookie</param><param name="wordLength">6</param><param name="imageWidth">90</param><param name="imageHeight">25</param></result>

其中的值可以根据自己需求设定。

如有一个Login的页面:

<s:form><s:textfield name="name" label="User Name"/><s:password name="password" label="Password"/><tr><td><img alt="" src="GetCaptchaImageAction.action"></td><td><s:textfield name="word" theme="simple" value=""/></td><s:submit value="Login"/></s:form>

在这个页面中有一个
<img alt="" src="GetCaptchaImageAction.action">

那么该Action就可以写为:

<action name="GetCaptchaImageAction"><result type="captcha"><param name="hashCookieName">hashCookie</param><param name="wordLength">6</param><param name="imageWidth">90</param><param name="imageHeight">25</param></result></action>


原创粉丝点击