波纹样式
web.xml
<servlet>
<servlet-name>ValidateCode</servlet-name>
<servlet-class>org.jelly.image.ValidateCode</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ValidateCode</servlet-name>
<url-pattern>/idCode</url-pattern>
</servlet-mapping>
jsp
<img src="idCode" onclick="this.src+=‘‘" style="cursor:pointer;" width="115" height="30" title="看不清?换一个">
结果图:
阴影样式
web.xml
<servlet>
<servlet-name>ValidateCode</servlet-name>
<servlet-class>org.jelly.image.ValidateCode</servlet-class>
<init-param>
<param-name>style</param-name>
<param-value>shadow</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>ValidateCode</servlet-name>
<url-pattern>/idCode</url-pattern>
</servlet-mapping>
jsp
<img src="idCode" onclick="this.src+=‘‘" style="cursor:pointer;" width="115" height="30" title="看不清?换一个">
结果图:
鱼眼样式
web.xml
<servlet>
<servlet-name>ValidateCode</servlet-name>
<servlet-class>org.jelly.image.ValidateCode</servlet-class>
<init-param>
<param-name>style</param-name>
<param-value>fishEye</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>ValidateCode</servlet-name>
<url-pattern>/idCode</url-pattern>
</servlet-mapping>
jsp
<img src="idCode" onclick="this.src+=‘‘" style="cursor:pointer;" width="115" height="30" title="看不清?换一个">
结果图:
二维码
基于 Servlet 实现,在 web.xml 中配置即可使用。并支持自定义样式,常用的配置项见下表:
使用默认样式
web.xml
<servlet>
<servlet-name>Qrcode</servlet-name>
<servlet-class>org.jelly.image.Qrcode</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Qrcode</servlet-name>
<url-pattern>/qrcode</url-pattern>
</servlet-mapping>
jsp
<img src="qrcode?text=http://lychie.github.io/index.html">
结果图:
样式
web.xml
<servlet>
<servlet-name>Qrcode</servlet-name>
<servlet-class>org.jelly.image.Qrcode</servlet-class>
<init-param>
<param-name>foreground</param-name>
<param-value>pink</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Qrcode</servlet-name>
<url-pattern>/qrcode</url-pattern>
</servlet-mapping>
jsp
<img src="qrcode?text=http://lychie.github.io/index.html">
结果图:
原文地址:http://www.blogjava.net/fancydeepin