标签:path idc geo 输出 splay 后台 function plain eof
第一种
第一步: JSP
<li><input name="validCode" id="validCode" type="text" class="loginvalid" value="" onclick="JavaScript:this.value=‘‘"/><img src="${path}/patchca.htm" id = "patchca" style="display:inline-block; float:right;width:100px; height:48px;line-height:48px;margin-right:100px;padding:0;"></li>
第二步: 后台
@RequestMapping("/patchca.htm")
public void patchca(HttpServletResponse response,HttpSession session) throws IOException
{
CaptchaService cs = new CaptchaService();
response.setContentType("image/png");
response.setHeader("cache", "no-cache");
OutputStream os = response.getOutputStream();
String patchca = EncoderHelper.getChallangeAndWriteImage(cs, "png", os);
session.setAttribute("PATCHCA", patchca);
os.flush();
os.close();
cs = null;
}
第二种
Controller:生成验证码
jsp:显示验证码
验证:
获取session中的code与前台传回的code是否一致
工具类:
最后展示:
标签:path idc geo 输出 splay 后台 function plain eof
原文地址:http://www.cnblogs.com/yhtboke/p/6349490.html