加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Ajax登录

发布时间:2020-12-16 03:30:27 所属栏目:百科 来源:网络整理
导读:! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" xmlns = "http://www.w3.org/1999/xhtml" head meta http - equiv = "Content-Type" content = "text/html; charset=utf-8" /
 
 
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< xmlns = "http://www.w3.org/1999/xhtml" >
< head >
< meta http - equiv = "Content-Type" content = "text/html; charset=utf-8" />
< title > 欢迎登录后台管理系统 </ title >
< link href = "css/style.css" rel = "stylesheet" type = "text/css" />
< script language = "JavaScript" src = "js/jquery.js" ></ script >
< "js/cloud.js" "text/javascript" ></ script >
< "javascript" >
$ ( function (){
$ ( ' . loginbox ' ). css ({ ' position ':' absolute ',' left ' :( window ). width ()- 692 )/ 2 });
resize ( function (){
2 });
})
});
</ script >
</ head >
< body style = "background-color:#df7611; background-image:url(images/light.png); background-repeat:no-repeat; background-position:center top; overflow:hidden;" >
< div id = "mainBody" >
< "cloud1" class =" cloud "></div>
<div id=" cloud2 " class=" cloud "></div>
</div>
<div class=" logintop ">
<span>欢迎登录后台管理界面平台</span>
<ul>
<li><a href=" # ">回首页</a></li>
<li><a href=" ">帮助</a></li>
<li><a href=" ">关于</a></li>
</ul>
</div>
<div class=" loginbody ">
<span class=" systemlogo "></span>
<div class=" loginbox ">
<ul>
<li><input name="" type=" text loginuser " value=" admin " onclick=" JavaScript: this . value = '' "/></li>
<li><input name="" type=" loginpwd " value=" 密码 "/></li>
<li><input name="" type=" button loginbtn 登录 javascript: window . location = main . html ' " /><label><input name="" type=" checkbox " value="" checked=" checked " />记住密码</label><label><a href=" ">忘记密码?</a></label></li>
</ul>
</div>
</div>
<div class=" loginbm ">版权所有 2014 <a href=" http: //www.uimaker.com">uimaker.com</a> 仅供学习交流,勿用于任何商业用途</div>
</ body >
</ html >
****************************************************************************************************************
js 页面
var xmlhttp ;
function getload ()
{
document . getElementById ( "loginname" ). focus ();
}
getIE ()
{
if ( XMLHttpRequest )
{
xmlhttp = new XMLHttpRequest ();
}
else
{
ActiveObject ( "Microsoft.XMLHTTP" );
}
}
loginname ( obj )
{
getIE ();
name = obj . value ;
name . length == 0 )
{
"nameflag" ). innerHTML = "<font color=red></font>" ;
"Loginbtn" ). style . visibility = "hidden" ;
}
else
{
url = "${pageContext.request.contextPath}/emp_myname.action?name=" + name ;
myurl = encodeURI ( url );
xmlhttp . open ( "post" , myurl , true );
send ();
onreadystatechange = getBack ;
}
}
getBack ()
{
readyState == 4 && status == 200 )
{
responseText == 1 )
{
"" ;
"visible" ;
}
else
{
"<font color=red></font>" ;
"hidden" ;
}
}
}
login (){
getIE ();
name = value ;
psw = "loginpsw" ). value ;
0 ){
"<font color=red></font>" ;
} else psw . 0 ){
alert ( "瀵嗙爜涓嶈兘涓虹┖" );
} else {
url = encodeURI ( "${pageContext.request.contextPath}/emp_getlogin.action?name=" + name + "&" + "psw=" + psw );
url , true );
send ();
onreadystatechange = loginback ;
}
}
//回滚
loginback (){
if ( readyState == 4 && status == 200 ) {
1 ){
location . href = "./main.jsp" ;
} else {
"xx" ). innerHTML = "<font color=red></font>" ;
return false ;
}
}
}
*********************************************************************************************
Action
//获得登录名
public String myname ()
{
int result = 0 ;
try
{
String myname = String ( getBytes ( "ISO8859_1" ), "utf-8" );
int t = empService . getLoginName ( myname );
HttpServletResponse response = ServletActionContext . getResponse ();
response . setContentType ( "text/html;charset=UTF-8" );
PrintWriter out = getWriter ();
t > 0 )
{
1 ;
}
else
{
0 ;
}
out . println ( result );
flush ();
close ();
}
catch ( Exception e )
{
e . printStackTrace ();
}
null ;
}
//登录
getlogin (){
int result = 0 ;
try {
myname = String ( name . "utf-8" );
mypsw = psw . "utf-8" );
TEmp e = TEmp ();
setELoginname ( myname );
setEPsw ( mypsw );
int getLogin ( e );
getResponse ();
"text/html;charset=UTF-8" );
getWriter ();
0 )
{
1 ;
}
else
{
0 ;
}
result );
flush ();
close ();
} e ) {
printStackTrace ();
}
null ;
}
*******************************************************************************************
Dao
//得到登录名字
public int getLoginName ( name ){
List ar = getHibernateTemplate (). find ( "from TEmp where ELoginname = ?" ,239)">name );
return ar . size ();
}
//登录查询
List getLoginCount ( final emp ) {
return getHibernateTemplate (). executeFind ( HibernateCallback () {
Object doInHibernate ( Session session )
throws HibernateException ,239)">SQLException {
session . createQuery ( " from TEmp t where t.ELoginname = ? and t.EPsw =?" ). setString ( 0 ,239)">emp . getELoginname ()). 1 ,255)">getEPsw ()). list ();
ar ;
}
});
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读