ext logon



<html>
<head>
<title>供应商服务系统 V1.0</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="js/ext/resources/css/ext-all.css" />
<script type="text/javascript" src="js/ext/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="js/ext/ext-all.js"></script>
<script type="text/javascript" src="js/ext/build/locale/ext-lang-zh_CN.js"></script>
<script type="text/javascript" src="js/logon.js"></script>
</head>

<body>

</body>
</html>




Ext.onReady(function(){
Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = 'side';

var login = new Ext.FormPanel({
labelWidth:70,
labelAlign :'right',
frame:true,
defaults: {width: 170},
bodyStyle:'padding:10px 5px 0',
defaultType:'textfield',
monitorValid:true,
items:[{
fieldLabel:'用户帐号',
name:'userId',
emptyText:'请输入用户帐号',
allowBlank:false
},{
fieldLabel:'用户密码',
name:'password',
inputType:'password',
allowBlank:false
}],

buttons:[{
text:'登录',
formBind: true,
// Function that fires when user clicks the button
handler:function(){
login.getForm().submit({
method:'POST',
waitTitle:'系统提示',
waitMsg:'正在登录,请稍候...',
url:'Logon.do',

// Functions that fire (success or failure) when the server responds.
// The one that executes is determined by the
// response that comes from Logon.do as seen below. The server would
// actually respond with valid JSON,
// something like: response.write "{ success: true}" or
// response.write "{ success: false, errors: { reason: 'Login failed. Try again.' }}"

success:function(){
var redirect = 'index.html';
window.location = redirect;
},

// Failure function, see comment above re: success and failure.
// You can see here, if login fails, it throws a messagebox
// at the user telling him / her as much.

failure:function(form, action){
if(action.failureType == 'server'){
obj = Ext.util.JSON.decode(action.response.responseText);
Ext.Msg.alert('登录失败', obj.errors.reason,function() {form.findField('userId').focus();});
}else{
Ext.Msg.alert('Warning!', 'Authentication server is unreachable : ' + action.response.responseText);
}
}
});
}
}]
});


// This just creates a window to wrap the login form.
// The login object is passed to the items collection.
var win = new Ext.Window({
title:'用户登录',
layout:'fit',
border:false,
width:300,
//height:160,
closable: false,
resizable: false,
plain: true,
items: [login]
});
win.show();

});





package com.linbq.servlet;

import java.util.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.linbq.bean.*;

/** *//**
* 用户登录操作响应控制
* <p>对用户登录等响应请求进行处理.</p>
* @author linbq
*/

public class LogonServlet extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
String userId = request.getParameter("userId");
String password = request.getParameter("password");

//安全性检查,防止非法操作Servlet
if (userId == null || userId.length() == 0 || password == null || password.length() == 0) return;

response.setContentType("text/xml;charset=UTF-8");
response.setHeader("Cache-Control", "no-cache");
PrintWriter out=response.getWriter();
User user = new User();
if (user.logon(userId, password)) {
HttpSession session = request.getSession();
session.setAttribute("userId", user.getId());
session.setAttribute("userName", user.getName());
out.write("{ success: true}");
} else {
out.write("{ success: false, errors: { reason: '用户帐号或密码验证不通过.' }}");
}
out.close();
}

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
doGet(request, response);
}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值