日期:2014-05-20 浏览次数:20909 次
<%
String ccode=(String)request.getSession().getAttribute("ccode");
System.out.println("Jsp-->"+ccode);
%>
<html:form action="jsp/user.do" method="post">
用户ID:<html:text property="userid" onblur="checkUserName();"></html:text>
<span id="userIdMessage" style="width:200px ; height:10px;"></span>
<br>
用户密码:<html:password property="userpwd" onblur="checkPassWord();"></html:password>
<span id="pwdMessage" style="width:200px ; height:10px;"></span>
<br>
确认密码:<html:password property="confirmpwd" onblur="checkConfpwd();"></html:password>
<span id="confpwdMessage" style="width:200px ; height:10px;"></span>
<br>
丢失密码提示问题:<html:text property="userques"></html:text>
<br>
丢失密码问题答案:<html:text property="userans"></html:text>
<br>
验证码:<html:text property="checkcode" onblur="checkCode();"></html:text>
<img src="image.jsp">
<input type="hidden" name="ccode" value="<%=ccode%>">
<span id="checkcodeMessage" style="width:200px ; height:10px;"></span>
<br>
<input type="hidden" name="status" value="register">
<input type="hidden" name="type" value="1">
<html:submit value="注册"></html:submit>
<html:reset value="重置"></html:reset>
</html:form>
// 将认证码存入SESSION
session.setAttribute("ccode",sRand);
<img src="image.jsp?<%=Long.toString(System.currentTimeMillis(), 36)%>">
------解决方案--------------------
原因可能是验证码的还有没生成,你就在session当中拿了值,所以第一次就没有拿到。第二次~~~~~之后拿的就是上一次的值。。
你可另建一个servlet去session当中拿值试试。