日期:2014-05-19 浏览次数:20843 次
<script type="text/javascript">
/*
注册dojo事件用来显示验证码
*/
dojo.addOnLoad(function() {
dojo.event.topic.subscribe('/retrieveUser', this, function(data, type, e){
if(type == 'load') {
showUser(data);
} else if(type == 'error') {
alert('Can not retrieve the Vocde');
}
});
});
function showUser(strUser) {
var UserHolder = document.getElementById('im');
UserHolder.src ='getVocde.action';
}
</script>
<s:url id="userUrl" value="getVocde.action" />
<td colspan="2">
验证码
<input maxlength="4" size="2" name="logon.vcode">
<img border="0" src="getVocde.action" width="57" height="22" id="im"
align="middle">
<a target="main" href="MyCountManager/BSP_User_getpass.jsp"> 找回密码</a>
<sx:a href="%{userUrl}" notifyTopics="/retrieveUser">看不清,换一张</sx:a>
@Action(value ="getVocde", results = {@Result(name = "input", type = "stream",params={"contentType", "image/jpeg", "contentDisposition", "filename=document.jpeg","bufferSize", "1024"})})
public String execute()throws IOException {
VImage v=new VImage(); //这是生成验证码的servlet
try {
v.doGet(ServletActionContext.getRequest(), ServletActionContext.getResponse());
} catch (ServletException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return "input";
}