首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

Struts2+Spring2.5+ibatis+ExtJS3.1 基于注脚框架搭建(5)

2012-11-10 
Struts2+Spring2.5+ibatis+ExtJS3.1 基于注解框架搭建(5)1、BaseServicepublic class BaseService{/*** 返

Struts2+Spring2.5+ibatis+ExtJS3.1 基于注解框架搭建(5)
1、BaseService
public class BaseService
{
    /**
     * 返回日志对象
     *
     * @return
     * @see [类、类#方法、类#成员]
     */
    protected Logger getLog()
    {
        return Logger.getLogger(BaseAction.class);
    }
}

2、创建页面
login.jsp
<%@ page language="java"  pageEncoding="GBK"%>
<html>
<head>
    <title>Custom Layouts and Containers - Login Example</title>

    <!-- ** CSS ** -->
    <!-- base library -->
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/extjs3.1/resources/css/ext-all.css" />

    <!-- ** Javascript ** -->
    <!-- ExtJS library: base/adapter -->
    <script type="text/javascript" src="${pageContext.request.contextPath}/extjs3.1/adapter/ext/ext-base.js"></script>

    <!-- ExtJS library: all widgets -->
    <!--
    <script type="text/javascript" src="${pageContext.request.contextPath}/extjs3.1/ext-all.js"></script>
     -->
    <script type="text/javascript" src="${pageContext.request.contextPath}/extjs3.1/ext-all-debug.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/extjs3.1/ext-lang-zh_CN.js" charset="utf-8"></script>

<script type="text/javascript" src="${pageContext.request.contextPath}/js/login/login.js"></script>

</head>
<body>
<div id="loginPanel" align="center"></div>
</body>
</html>


login.js

/*!
* Ext JS Library 3.1.1
* Copyright(c) 2006-2010 Ext JS, LLC
* licensing@extjs.com
* http://www.extjs.com/license
*/
Ext.onReady(function() {
Ext.QuickTips.init();   //用于消息提示
    Ext.form.Field.prototype.msgTarget = 'side'; 
   
    var loginForm = new Ext.form.FormPanel({
        baseCls: 'x-plain',
        layout:'absolute',
        defaultType: 'textfield',

        items: [{
            x: 0,
            y: 5,
            xtype:'label',
            text: 'StaffNo:'
        },{
            x: 60,
            y: 0,
            name: 'staffId',
            anchor:'100%',  // anchor width by percentage
            allowBlank: false,  
            blankText: 'StaffNo is not null'
        },{
            x: 0,
            y: 35,
            xtype:'label',
            text: 'password:'
        },{
            x: 60,
            y: 30,
            name: 'staffPwd',
            inputType:'password',
            anchor: '100%',  // anchor width by percentage
            allowBlank: false,  
            blankText: 'staffPwd is not null'
        }]
    });

    var window = new Ext.Window({
        title: 'Login System',
        width: 300,
        height:150,
        layout: 'fit',
        plain:true,
        bodyStyle:'padding:5px;',
        buttonAlign:'center',
        items: loginForm,
   
        keys:{  
            key: 13,  
            fn:loginAction  
        },  
        buttons: [{
            text: 'Send',
            handler:loginAction
        },{
            text: 'Cancel',
            handler:function(){
                loginForm.form.reset();
            }
        }]
    });

    window.show();
   
    //登录Action
    function loginAction()
    {
       
        //可以增加校验
        loginForm.form.submit({
            waitMsg:'正在登录...', /* 表示提交过程中间的等待信息。 */ 
            url:'/NGFRAME/login/loginAction.action', /* 表示表单提交的时候的路径。 */  
            method:'post',
            success: onLoginSuccess, /* 服务器返回正确的信息之后我们调用的方法。 */  
            failure: onFailure /* 服务器返回错误的信息之后我们调用的方法。 */  
        });  
        return;
    }
   
    //登录成功
    function onLoginSuccess()
    {
        //Ext.Msg.alert('success', 'Changes saved successfully.');
    }
    //登录失败
    function onFailure()
    {
        Ext.Msg.alert('failure', '登录失败!,用户名或密码错误');
    }
});

热点排行