Java SSI框架學習總結


文章轉自http://www.open-open.com/lib/view/open1377581482589.html

框架簡介:

相信大家對於mvc的三層架構已經灰常熟悉了,在這就不細講了,個人感覺ssi的框架結構還是比較典型的mvc三層架構,還是比較容易上手的。關於這塊的入門我想特別感謝下FrankHui童鞋,在他的幫助下,我才能比較快滴熟悉了這個架構,對我學習ssi的框架還是很有幫助滴。ssi的框架主要是由struts2,spring以及ibatis組成,他們負責各層之間的交互與協作,從而實現整個web端的功能實現與整合。Struts目前主要負責數據傳遞和控制方面,spring則依靠其強大的依賴注入技術實現了類似bean托管和整合等功能,當然這只是spring功能中的冰山一角,而ibatis作為一種輕量級的OR Mapping框架,提供了半自動化對象關系映射的實現,自由度相對於hibernate更高。

框架結構:

這是我在網上找到的一張關於ssi框架的結構圖,個人感覺畫的還是蠻不錯的,對於入門者來說,層次機構很清晰,比較實用(感謝這位大大的分享):

ssi框架學習總結

在這里可以很明顯的看出ssi框架的大體結構以及各層之間的交互情況,頂層表現層的話,就java而言主要是jsp,html等視圖層技術的編寫,其中涉及我們熟悉的javascript,jquery以及extjs等。在控制層來說的話,主要是利用strust2標簽功能實現action與視圖層的數據交互,當然也可以使用ajax的技術實現同樣的功能,這個就按個人喜好而來了。在業務邏輯層。主要是利用spring的依賴注入實現對業務邏輯類和dao類的實例托管,當然各類的實例都可以托管在spring中進行統一管理和關聯,包括事務,數據源等等。在持久層,利用ibatis提供的半自動化對象關系映射的實現,開發人員可以根據需要編寫具體的sql語句,通過相應的xml的配置實現對數據庫的操作。

總之,SSI框架能夠降低我們代碼的耦合度,增強了代碼的健壯性和可重用性,加快了開發速度,但是也有一些不足之處,比如由於三種框架的配置文件較多,也給我們帶來了一些不便,特別是對於較小的應用來說更是如此。

相關demo介紹:

基於之前對ssi框架的學習,我也不能免俗滴選擇了做一個用戶管理的web實現,項目的大致框架如下:

ssi框架學習總結

大體上還是按照三層的分層模型來是分的,具體就不詳細說了,相信大家也應該很了解整個結構的。

Ø  開發環境簡介:

工具:eclipse3.6+tomcat7+mysql5.1

框架:struts2,spring3.0.5,ibatis2.3.4.726

開發步驟及配置簡介:

第一步,眾所周知肯定是導入相關的lib庫啦,由於我使用的前端是extjs,所以還需要導入extjs相關的js以及css依賴文件。由於lib庫太多就不截圖了,只截取extjs的相關依賴文件:

ssi框架學習總結

這樣基本的環境就有了,數據庫的設計則需要根據model層的對象來確定。 

第二步,建立相關的model層,代碼如下:

User.java:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.broada.demo.entity;
/**
  *
  * @author smm
  *
  */
public class User {
 
     private int id;           //用戶id
     private String name;         //用戶名稱
     private String password;     //用戶密碼
     private String username;     //用戶昵稱
     private String address;      //地址
 
     
     public String getUsername() {
         return username;
     }
 
     public void setUsername(String username) {
         this .username = username;
     }
 
     public String getAddress() {
         return address;
     }
 
     public void setAddress(String address) {
         this .address = address;
     }
 
     public int getId() {
         return id;
     }
 
     public void setId( int id) {
         this .id = id;
     }
 
     public String getName() {
         return name;
     }
 
     public void setName(String name) {
         this .name = name;
     }
 
     public String getPassword() {
         return password;
     }
 
     public void setPassword(String password) {
         this .password = password;
     }
 
}

第三步,strust的相關配置,這里就不詳細講述strust的單獨配置及原理了,直接上實例中的相關配置文件,主要是strust.xml以及web.xml的相關配置,部分主要配置如下:

Web.xml:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
<!-- struts2模塊 -->
     < filter >
         < filter-name >struts2</ filter-name >
        <!-- 這個就是struts2的核心過濾器 -->
         < filter-class >
            org.apache.struts2.dispatcher.FilterDispatcher
         </ filter-class >
         
     </ filter >
     < filter-mapping >
         < filter-name >struts2</ filter-name >
         < url-pattern >/*</ url-pattern >
     </ filter-mapping >

strust.xml:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<? xml version = "1.0" encoding = "UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
< struts >
     <!-- 這是一個重要的地方,很多人在使用<s:include>子頁面后,發現子頁面亂碼,怎么改都不行,原因就在次,struts2的默認編碼為UTF-8,亂碼的同志請看看你的jsp頁面上的編碼是不是和這個不一致呢。只要把這里和jsp編碼改一致就行了 -->
     < constant name = "struts.i18n.encoding" value = "UTF-8" />
     <!-- 告訴struts2,我要用spring裝配工廠,其實默認就是這個了-_-!!! -->
     < constant name = "struts.objectFactory" value = "spring" />
     <!-- struts2的擴展名,比如struts1的時候,用的.do,struts2默認為.action,可以改成其它的,比如.dxd -->
     < constant name = "struts.action.extension" value = "action" />
     <!-- 資源文件 -->
     < constant name = "struts.custom.i18n.resources"
         value = "messageResource" >
     </ constant >
 
     <!-- 用戶注冊類 -->
     <!-- abstract屬性就說明了該action繼承自自己定義的基礎action,而class采用的registerAction是由spring產生的 -->
     < package name = "register" extends = "struts-default" >
         < action name = "register" class = "registerAction" method = "addUser" >
             <!-- 注冊成功 -->
             < result name = "success" >success.jsp</ result >
             <!-- 注冊失敗 -->
             < result name = "input" >error.jsp</ result >
         </ action >
         < action name = "login" class = "registerAction" method = "loginUser" >
             <!-- 注冊成功 -->
             < result name = "success" >success.jsp</ result >
             <!-- 注冊失敗 -->
             < result name = "error" >error.jsp</ result >        
         </ action >
     </ package >
</ struts >

這樣strust的配置大致就完成了。 

第四步:配置ibatis的相關配置文件,主要是jdbc.properties,SqlMapConfig.xml以及User.xml的配置,jdbc.properties主要用於配置數據庫的數據源參數,會在加載spring的時候自動初始化,ibatis數據源的配置到時可以托管給spring初始化,所以這里就不細講了。SqlMapConfig.xml主要是配置ibatis的配置文件的位置,User.xml則用於編寫相關的數據庫語句等,配置大致如下:

jdbc.properties:

?
1
2
3
4
5
6
7
8
9
10
11
12
jdbc.driverClass=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql: //localhost:3306/userinfo
jdbc.user=root
jdbc.password= 123456
jdbc.minPoolSize= 5
jdbc.maxPoolSize= 20
jdbc.maxIdleTime= 1800
jdbc.acquireIncrement= 5
jdbc.maxStatements= 50
jdbc.initialPoolSize= 10
jdbc.idleConnectionTestPeriod= 1800
jdbc.acquireRetryAttempts= 30

詳細的參數含義在spring的配置文件會提及,就不細說了。

SqlMapConfig.xml:

?
1
2
3
4
5
6
7
<?xml version= "1.0" encoding= "UTF-8" ?>
<!DOCTYPE sqlMapConfig PUBLIC  "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-config-2.dtd" >
<sqlMapConfig>
<!-- 用戶信息表 -->
<sqlMap resource= "com/broada/demo/dao/ibaties/map/User.xml" />
</sqlMapConfig>

User.xml:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?xml version= "1.0" encoding= "UTF-8" ?>
<!DOCTYPE sqlMap PUBLIC  "-//ibatis.apache.org//DTD SQL Map 2.0//EN"     
"http://ibatis.apache.org/dtd/sql-map-2.dtd" >
<sqlMap>
     <typeAlias alias= "User" type= "com.broada.demo.entity.User" />
     <!-- 保存注冊信息 -->
     <insert id= "insertUser" parameterClass= "User" >
         insert into
         user (name,password,username,address)values(#name#,#password#,#username#,#address#)
     </insert>
     
     <select id= "selsectUser" parameterClass= "java.lang.String" resultClass= "User" >
         select * from user
         where name = #name#;
     </select>
</sqlMap>

這樣,ibatis的配置大致就完成。

第五步:配置spring的相關配置文件,主要是整合ibatis以及strust中用到的bean,需要配置web.xml以及applicationContext-web.xml兩個配置文件:

web.xml:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<listener>
         <!-- 這個就是今后用到的WebApplicationUtilContent -->
         <listener- class >
             org.springframework.web.context.ContextLoaderListener
         </listener- class >
     </listener>
     <!-- springframework config files -->
     <context-param>
         <param-name>contextConfigLocation</param-name>
         <!-- 把spring的配置文件放到了/WEB-INF/下的springframework包里,方便統一管理,命名規則是以applicationContent-開頭的xml文件,初始化時會自動搜索所有符合規則的配置文件 -->
         <param-value>
             /WEB-INF/spring/applicationContext-*.xml
         </param-value>
</context-param>

applicationContext-web.xml:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?xml version= "1.0" encoding= "UTF-8" ?>
<beans xmlns= "http://www.springframework.org/schema/beans"
     xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation= "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd" >
     <!-- 配置數據源,連接池采用的是c3p0,具體各參數代表意義參看c3p0自帶的doc,非常詳細。 -->
     <bean id= "dataSource"
        class = "com.mchange.v2.c3p0.ComboPooledDataSource"
         destroy-method= "close" >
         <property name= "driverClass" value= "${jdbc.driverClass}" />
         <property name= "jdbcUrl" value= "${jdbc.url}" />
         <property name= "user" value= "${jdbc.user}" />
         <property name= "password" value= "${jdbc.password}" />
         <property name= "minPoolSize" value= "${jdbc.minPoolSize}" />
         <property name= "maxPoolSize" value= "${jdbc.maxPoolSize}" />
         <property name= "maxIdleTime" value= "${jdbc.maxIdleTime}" />
         <property name= "acquireIncrement"
             value= "${jdbc.acquireIncrement}" />
         <property name= "maxStatements" value= "${jdbc.maxStatements}" />
         <property name= "initialPoolSize"
             value= "${jdbc.initialPoolSize}" />
         <property name= "idleConnectionTestPeriod"
             value= "${jdbc.idleConnectionTestPeriod}" />
         <property name= "acquireRetryAttempts"
             value= "${jdbc.acquireRetryAttempts}" />
     </bean>
 
     
    <!-- 上面的數據源的value值用的是表達式,原因就在這里,這將配置文件放到了iBatis目錄下,也就是jdbc.properties,設置了c3p0的各項參數 -->
     <bean id= "propertyConfig"
        class = "org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" >
         <property name= "location" >
             <value>/WEB-INF/ibatis/jdbc.properties</value>
         </property>
     </bean>
     
     <!-- 配置iBatis的sqlMapClient,這里當然是交給了spring去處理,其中,將SqlMapConfig文件放到了WEB-INF的iBatis目錄下,也是便於管理 -->
     <bean id= "sqlMapClient"
        class = "org.springframework.orm.ibatis.SqlMapClientFactoryBean" >
         <property name= "configLocation" >
             <value>/WEB-INF/ibatis/SqlMapConfig.xml</value>
         </property>
         <!-- 這里使用的數據源就是上面配置的數據源 -->
         <property name= "dataSource" >
             <ref bean= "dataSource" />
         </property>
     </bean>
 
     <bean id= "userdaoId"  class = "com.broada.demo.daoImpl.UserDaoImpl" >
         <property name= "sqlMapClient" ref= "sqlMapClient" ></property>
     </bean>
      
     <bean id= "userDaoServiceId" class = "com.broada.demo.serviceImpl.UserDaoServiceImpl" >
       <property name= "userdao" ref= "userdaoId" >
     </property>
     </bean>
      <!-- 用戶注冊action-->
     <bean id= "registerAction" name= "registerAction"  class = "com.broada.demo.action.RegisterAction" scope= "prototype" >      
       <property name= "userdaoServiceInter" ref= "userDaoServiceId" ></property>
     </bean>
     
     
</beans>

這樣,ssi框架的大致配置就完成了。 

最后編寫相關的dao層,service層,action層以及jsp等等,我就不詳細說明了,直接上相關代碼:

RegisterAction.java:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package com.broada.demo.action;
 
/**
  * @author smm
  */
 
import com.broada.demo.entity.User;
import com.broada.demo.service.UserDaoServiceInter;
import com.opensymphony.xwork2.ActionSupport;
 
public class RegisterAction  extends ActionSupport {
     
     private static final long serialVersionUID = 1L;
     
private UserDaoServiceInter userdaoServiceInter;   
 
     public UserDaoServiceInter getUserdaoServiceInter() {
         return userdaoServiceInter;
     }
 
     public void setUserdaoServiceInter(UserDaoServiceInter userdaoServiceInter) {
         this .userdaoServiceInter = userdaoServiceInter;
     }
 
     private String name;     //用戶名
     private String password;     //密碼
     private String username;     //昵稱
     private String address;      //地址
 
     public String getUsername() {
         return username;
     }
 
     public void setUsername(String username) {
         this .username = username;
     }
 
     public String getAddress() {
         return address;
     }
 
     public void setAddress(String address) {
         this .address = address;
     }
 
     public String getName() {
         return name;
     }
 
     public void setName(String name) {
         this .name = name;
     }
 
     public String getPassword() {
         return password;
     }
 
     public void setPassword(String password) {
         this .password = password;
     }
 
     public String addUser() {
         System.out.println( "添加成功!" );
         User user =  new User();
         
         String name =  this .name;
         String password =  this .password;
         String username =  this .username;
         String address =  this .address;
         
         user.setName(name);
         user.setPassword(password);
         user.setUsername(username);
         user.setAddress(address);
         
         boolean b = userdaoServiceInter.insertUser(user);
         
         if (b== true ) {
             return SUCCESS;
         else
             return INPUT;
     }
     
     public String loginUser(){
         System.out.println( "登陸=======" );
         
         String name =  this .name;
         String password =  this .password;
         
         User user = userdaoServiceInter.querybyname(name);
         
         if (user !=  null && password.equals(user.getPassword())){
             return SUCCESS;
         else
             return ERROR;
     }
}

UserDao.java:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package com.broada.demo.dao;
 
/**
  * @author smm
  */
 
import java.util.List;
 
import com.broada.demo.entity.User;
 
public interface UserDao {
     
     /**
      * 用戶注冊
      * @param user
      * @return
      */
     
     public boolean insertUser(User user);
     
     /**
      * 根據用戶名獲取用戶信息
      * @param name
      * @return
      */
     
     public User queryByname(String name);  
}

UserDaoImpl.java:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.broada.demo.daoImpl;
/**
  * @author smm
  */
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
 
import com.broada.demo.dao.UserDao;
import com.broada.demo.entity.User;
 
public class UserDaoImpl  extends SqlMapClientDaoSupport  implements UserDao{
 
 
 
     @Override
     public boolean insertUser(User user) {
         try {
             getSqlMapClientTemplate().insert( "insertUser" , user);
             return true ;
         catch (Exception e) {
             e.printStackTrace();
             return false ;
         }  
     }
 
     @Override
     public User queryByname(String name) {
         // TODO Auto-generated method stub
         try {
             User user =(User) getSqlMapClientTemplate().queryForObject( "selsectUser" , name);
             return user;
         catch (Exception e) {
             e.printStackTrace();
             return null ;
         }      
     }
     
}

UserDaoServiceInter.java:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package com.broada.demo.service;
 
/**
  * @author smm
  */
 
import com.broada.demo.entity.User;
 
public interface UserDaoServiceInter {
     
     /**
      * 用戶注冊服務接口
      * @param user
      * @return
      */
     
     public boolean insertUser(User user);
     
     /**
      * 根據用戶名獲取用戶信息接口
      * @param name
      * @return
      */
     
     public User querybyname(String name);
}

UserDaoServiceImpl.java:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package com.broada.demo.serviceImpl;
 
/**
  * @author smm
  */
 
import com.broada.demo.dao.UserDao;
import com.broada.demo.entity.User;
import com.broada.demo.service.UserDaoServiceInter;
 
public class UserDaoServiceImpl  implements UserDaoServiceInter {
 
     private  UserDao userdao;
     public UserDao getUserdao() {
         return userdao;
     }
     public void setUserdao(UserDao userdao) {
         this .userdao = userdao;
     }
     @Override
     public boolean insertUser(User user) {
         return userdao.insertUser(user);
     }
     @Override
     public User querybyname(String name) {
         // TODO Auto-generated method stub
         return userdao.queryByname(name);
     }
 
}

Index.jsp:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<%@ page language= "java" contentType= "text/html; charset=utf8"
     pageEncoding= "utf8" %>
     <%@ taglib prefix= "s" uri= "/struts-tags" %>
<!DOCTYPE html PUBLIC  "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" >
<html>
<head>
<meta http-equiv= "Content-Type" content= "text/html; charset=utf8" >
<link rel= "stylesheet" type= "text/css" href= "css/ext-all.css" />
<link rel= "stylesheet" type= "text/css"
     href= "css/ext-theme-classic-all.css" />
<script type= "text/javascript" src= "js/ext-all.js" ></script>
 
 
<title>用戶登陸</title>
<script type= "text/javascript" >
Ext.onReady(function(){
         initPanel();    
     });
     
     initPanel=function(){
          var formPanel =  new Ext.FormPanel({
                 id:  'loginPanel' ,
                 labelWidth:  75 ,
                 frame: true ,
                 bodyStyle: 'margin:0 auto' ,
                 width:  350 ,
                 defaults: {width:  250 },
                 defaultType:  'textfield' ,
                 items: [{id:  'username' ,fieldLabel:  '用戶名' ,name: 'name' ,allowBlank:  false ,blankText:  '賬號不能為空' },
                {id:  'password' , fieldLabel:  '密 碼' ,name: 'password' ,inputType:  'password' ,allowBlank:  false ,blankText:  '密碼不能為空' }]
                      });
         var win =  new Ext.Window({  
                title: '登陸界面' ,
                width: 380 ,
                autoHeight:  'true' ,
                resizable:  false ,
                modal: true ,
                closeAction:  'hide' ,
                buttonAlign: 'center' ,
                items:formPanel,
                buttons:[{text:  '登陸' ,handler: function(){land();}},
                         {text:  '重置' ,handler: function(){
                            Ext.getCmp( 'username' ).setValue( "" );
                            Ext.getCmp( 'password' ).setValue( "" );
                            }},{text:  '注冊' ,handler: function(){register();}}]
                   });
                          
         win.show();
     };
     
     var win1;
     
     register = function(){ 
         
         var registerPanel =  new Ext.FormPanel({
             id:  'registerPanel' ,
             labelWidth:  75 ,
             frame: true ,
             bodyStyle: 'margin:0 auto' ,
             width:  350 ,
             defaults: {width:  250 },
             defaultType:  'textfield' ,
             items: [{id:  'registername' ,fieldLabel:  '用戶名' ,name: 'name1' ,allowBlank:  false ,blankText:  '賬號不能為空' },
            {id:  'registerpassword' , fieldLabel:  '登陸密 碼' ,name: 'password1' ,inputType:  'password' ,allowBlank:  false ,blankText:  '密碼不能為空' },
            {id:  'registerpassword2' , fieldLabel:  '密碼確認' ,name: 'password2' ,inputType:  'password' ,allowBlank:  false ,blankText:  '密碼不能為空' },
            {id:  'nichen' ,fieldLabel:  '昵稱' ,name: 'nichen1' },
            {id:  'address' ,fieldLabel:  '地址' ,name: 'address1' }]
                  });
         
         win1 =  new Ext.Window({  
                title: '注冊界面' ,
                width: 380 ,
                autoHeight:  'true' ,
                resizable:  false ,
                modal: true ,
                buttonAlign: 'center' ,
                items:registerPanel,
                buttons:[{text:  '提交' ,handler: function(){login();}},
                         {text:  '取消' ,handler: function(){win1.close();}}]
                   });
                          
         win1.show();
     };
     
     login=function(){
         var name = Ext.getCmp( 'registername' ).getValue();
         var password = Ext.getCmp( 'registerpassword' ).getValue();
         var password2 = Ext.getCmp( 'registerpassword2' ).getValue();
         var nichen = Ext.getCmp( 'nichen' ).getValue();
         var address = Ext.getCmp( 'address' ).getValue();
         
         if (name== " " || password== " " || password2== "" ){
             Ext.MessageBox.alert( '提示' , '賬號或密碼不能為空!' );
         }
         else if (password != password2){
             Ext.MessageBox.alert( '提示' , '兩次密碼輸入不一致!' );
         } else {
          Ext.Ajax.request({
              url:  "<s:url value='/register.action'/>" ,
              method:  'post' ,
             params:{
                 name:name,
                 password:password,
                 username:nichen,
                 address:address
             },
              success: function (response, options) {
                 Ext.MessageBox.alert( '提示' , '注冊成功' ,function(e){
                     if (e ==  "ok" ){
                         win1.close();
                     }
                  });
                 
              },
              failure: function (response, options) {
                  Ext.MessageBox.alert( '注冊失敗' '請檢查您的注冊信息!' );
              }
          });
         }
     };
     
     land=function(){
         var name = Ext.getCmp( 'username' ).getValue();
         var password = Ext.getCmp( 'password' ).getValue();
         
         
         if (name ==  " " || password ==  "" ){
              Ext.MessageBox.alert( '提示' '賬號或密碼不能為空!' );
         }
         else {
          Ext.Ajax.request({
              url:  "<s:url value='/login.action'/>" ,
              method:  'post' ,
             params:{
                 name:name,
                 password:password              
             },
              success: function (response, options) {
                 Ext.MessageBox.alert( '提示' , '登陸成功!' );
                 
              },
              failure: function (response, options) {
                  Ext.MessageBox.alert( '登陸失敗' '您輸入的賬號或密碼錯誤!' );
              }
          });
         }
     };
     
</script>
 
</head>
<body>
     
</body>
</html>

大致的步驟就是這樣,個人覺得ssi的框架還是蠻不錯的,起碼定制和自由度都比較好。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM