这个当然是有问题的,呵呵,ajax不可能提前预知你需要查询的用户名~
解决方案 »
- 第一次写关于ssh程序 如何判断是否写对了每一步?大侠给支支招
- 当tomcat报:java.lang.OutOfMemoryError: Java heap space
- 求高手指点,struts2 的一个简单问题
- 关于Java的Webservice传类数组的!在线等(分不多了请大家多包含)
- Apache2.2.4+Tomcat6.0 整合 问题..........
- JComboBox如何读取数据库里的数据并填充到JComboBox里.????
- 单态类中的 公用方法与静态方法使用的讨论?
- 关于jTable的问题,如何在表格中的cell中点击“回车”后,让焦点移动到该列的下行去????
- 帮助呀!JB9的问题?
- 如何通过XML配置把DAO注入到SERVICE 把service注入到actiton
- 关于AJAX的大家务必帮忙!谢谢了!
- java正则表达式匹配
直接写在JSP页面上,然后点击一个"验证"链接样式,如果用户存在"验证"两个字就变成"用户已存在,请重新输入"这样的可以不?
可以就写给你看.
<td><div id="confirmDiv"></div></td><script type="text/javascript">
<!--
var __ajaxRequest=false;
var __inited=false;
var __container=false;
function __init(){
__inited=true;
if(window.ActiveXObject){
try{
__ajaxRequest=new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
__ajaxRequest=new ActiveXObject("Microsoft.XMLHTTP");
}catch(ee){
}
}
}
if(!__ajaxRequest){
alert("can't init");
}else{
__ajaxRequest.onreadystatechange=function(){
if(__ajaxRequest.readyState==4){
if(__ajaxRequest.status==200){
confirmDiv.innerText=__ajaxRequest.responseText;
}
}
};
__ajaxRequest.open("POST","*.do",true);
__ajaxRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
}
}
function __sendData(){
if( userRegForm.userName.value == ""){
confirmDiv.innerText = "请先填写用户名";
return ;
}
__init();
var data = "userName="+ userRegForm.userName.value;
__ajaxRequest.send(data);
}
//-->
</script>
在.do里验证然后写出来error
String result = "";
if( checkUserExists(name) ) {
result = getResources(request, "abc").getMessage("已存在此用户名");
} else {
result = getResources(request, "abc").getMessage("此用户名未被使用");
}
try {
response.setContentType("text/html; charset=gb2312");
response.getWriter().println(result);
}catch(Exception e) {
e.printStackTrace();
}
public checkUserExists(String name){
验证
}
我的帖子---->里面-->点击 管理