基于Stripes框架的Ajax应用与研究

horseheadssolidInternet and Web Development

Nov 10, 2013 (3 years and 6 months ago)

321 views

 22 ﻭ  1
2012  1
ﳆ ﯣ ﯺ ﲼ 﫵   
C0 MPUTE R TE CHN OLOGY A ND DE VEL OPME NT
V n122 No1
J an 2012
ﯹ  Stripes ￲ ﳜ  Aj ax     ﺿ
  麟 隆 
( ﯄    ﳆ ﯣ ﯺ   ﯄    610065)
  Web 20 缾   ﺭ     龜   Web20 ﷸ    遲   ﮧ ﳥ   ﲰ  ↓  﫽 ﻝ  﫤   難 ᆰ   ﯹ   
  ﻊ ﳢ  Ajax ﺪ Web20     律 ﳼ ﲼ 﫵   ﳡ   ﮧ ﳥ  ﳵ 慄 ﷸ   﫤     ﻞ ￉ ﳦ        
 狀  MVC￲ ﳜ Stripes    ﻄ ﳾ 慄  ᄚ       ﺪ J avaᆰ        難 ﯹ   ﻄ  ﳡ      𢡊
Stripes+Aj ax  ﳜ 惡   難  ᆰ      ↓  ﳲ ﷠   諾 ﷸ  Ajaxᆰ  ﶬ 缾 ﻄ  ﮹ ﳡ   Stri pes  Aj ax     﫽
ﻝ  﫤  諾 ﳡ     Ajax﫽 ﻝ  﫤   
律 ﳼ  Stripes￲ ﳜ Ajaxﲼ 﫵 Web 20Jquery¬ JavaScript ￳  鉶
 ﶼ   鉶 TP31 ﻄ ᅲ  襁  A ﻄ   鉶 1673629X(2012)01000504
Aj ax Applications and Research Based on Stripes Framework
MA Chenggui GUAN Qun
(College of Computer Sichuan UniversityChengdu 610065China)
A bstract Web 2 0 era has come and how to make Web 20 site has good user experi ence an d faster data tran smission is important i ssues
of developers facingThe Aj ax as a key w eb 20 technologyhas an irrepl aceable role in improving the user experi encereduce network
tran smi ssionAnoth er new MV C framework Stripes with its low profi le short learning curve it is becomi ng the darling of J ava develop
ers Based on thisit proposes an integrated Stripes +Aj ax framework tO enable developers to the fastest an d most si mpl e way for Aj ax de-
velopment while it also proposes a variety of data tr an sfer format of Aj ax in Stri pes proposed a vari ety of Aj ax data transfer program 
K ey wor dsStripesAj axweb 20J query J avaScriptJ SON
0  
Web20 缾     調 Web ᆰ       
  ﶳ  Webᆰ   諾  Aj ax  Google Map  
簾    ﺪ web 20         Aj ax ﶨ 什 
 ﶨ  ↓   阮   ﮧ ﳥ  ﶬ 缾  ﲫ   ﳵ 慄  ﷸ
  ■ ﲫ   ﳡ      ﻊ ﷸ  缾      
 Web   ᆰ   什          鬒 
ﺿ  龜 ﺪ  ﮧ ﳡ 囹 ↓ ﯙ  ↓  鬒  遲  ﮥ  簾  
ﶥ  狀  﫜   ©  Web ᆰ  ￲ ﳜ  ﯼ    ﯹ
 MVC ￲ ﳜ  Struts2J SF TapestrySpringMVC
   難 ﯼ     難 﫴   ᄚ  ￟ ﷏   ￲ ﳜ 
   →    ﻕ ﯼ    ﷏   缾 ﳤ   ﷼  ᅱ
 Stripes￲ ﳜ         ￶ ﯼ     
 ﻄ ﳾ ﯹ  Action  ﯺ            
ﶬ 缾 ﯼ  難   ﺪ      ﻕ  MVC ￲ ﳜ 律 ﳼ
𥉉    20110531 ﯘ   20110904
ﯹ ﷰ ○  类  ﻥ 狀 ﳒ ᅥ ﲼ   ﳆ ﮮ   ○  (2006BAJ05A13)
  ﳲ ﷩   麟 (1986)  (    ) 麟  麟   ﮶ 謹  ﺿ 狀 
 ﺿ  ￲ ﺪ ﳆ ﯣ ﯺ ﷸ  隆   謹  ﷌ 﫚 ﮶ 謹  ﺿ 狀  益 
ﺿ  ￲ ﺪ ﷸ      ᄁ   GISICAI  
   ﯼ     i j ax
ﻄ   難 ﯹ  Stripes ﺿ  Aj ax     蝹
ᅱ ﶬ 缾  Ajax Stripes   﫽 ﻝ  﫤  諾 ﷸ  
ﺿ    ﺿ   﫽 ﻝ  﫤     𢡊 
1 Stri pes 鬒 Aj ax  ¢ 律 ﲼ 﫵 ﷩ 隆
11 Aj ax  捻   
Ajax    ﳲ   ﮵ ﶨ 什 XmlHttpRequest  ￳ 
ᅪ ﮧ  ￲  ﻱ         ﻱ  ﯱ  﫽 ﻝ  﫳
 J avaScript    DOM           律 ﳼ
   ﻍ 難  龜   ﻱ  ﯱ    﫽 ﻝ 
Ajax       難        ﯡ  ﶬ 
         﫽 ﻝ 難 Ajax  諾     ﶳ
Web 諾      ﳘ    難 ﯹ      
 蝹 ᅱ  遲   ﮧ ﳥ  鬒  遲   ﮧ ﶻ ﮥ  Ajax
  ﶳ Web 諾     ﶼ 1ﯹ 諭 
 ﶼ 1 ￉  ᄡ  Aj ax  諾   ﶳ Web 諾
      ﻍ 難 ajax    ﯘ  難 﫽 ﻝ ( XML da
ta)   ﶳ Web 諾   ﯘ   難  﫽 ﻝ  𢡊  
 ﷸ  (   html CSS鬒 data)    紐 ￉  ᄡ  

6  ﳆ ﯣ ﯺ ﲼ 﫵     22ﻭ
Ajax   ﳵ 慄  ﷸ   﫤  﫽 ﻝ    ￉  ᄡ  
 AJ ax  諾    難 ﶨ 什 J avaScript  Ajax   
ﷸ  Aj ax   ﶬ 缾  ﯘ  﫽 ﻝ ﶨ 什 J avaScript  ﷸ
    ﯦ  﫳  諭  ᅪ ﮧ  
_ |  
ᄌﷅ ar 0  ﷐ 
  t_ l  龎 | ﶫ n 襁 
| || l  ﳜ _ $ l l  llI  |l
﷐ (s)ﷂ l htq(s)rans or
$ j  t  ﺤ 龎g﫭| l I   
m  j t 
j  t  ll t    _ l ﶯ  﫭 | 
l _    m _  qm ﳗ
 eF瑱 甆 ﷣ ᄍ 
da~ic Aj ax
w e b a ppIica tlo n mo del w e b a pplica tio n mo de l
j _ -  G_     MdL
ﶼ 1 Aj ax   ﶳ web  諾   
12 Stripes ￲ ﳜ ﳲ ﷩
Stri pes 難   ᆰ   ﯹ  Action  J ava Web ￲
ﳜ  ﯼ 難       Web ᆰ  ﳲ     ﺪ  
 裡 ﳆ   ﶳ  J ava Webᆰ    ﶨ 什 ﯉  𢡊  裡
ﳆ    ﯮ ᆰ          狀     ﻄ ﳾ
(  struts)  ﷢  ￳  ﲰ  ﯼ  ﯩ       
ﳡ   ᆰ      ᄚ  ￟  Stri pes ﷪      
￲ ﳜ    ﯼ      J ava15       
 ﳘ    Annotations﮹    調     Con
vention over Confi guration      J ava   
ﳓ  慄   Annotationﻍ ￉  ﷪      ﳵ 慄 
   ﺬ ﮤ 捻   Stri pes ﳡ 囹  﫜   ﳘ    
     ﷢    ﻄ ﳾ  難 Stri pes     
 ﳘ     binding          ￳ 
 鬒    ﮻ ﯺ      調  鬒   ﮯ   ￉ 
﮵ Stri pesﶫ ﯡ  ﺪ ᅡ    ￲ ﳜ    
Stri pes       Stri pes  Web 捻   
ﯹ          webxml ﻄ ﳾ ﷪    web
xml    ﶬ 缾     StripesFilter 鬒   Dispatch
erServlet StripesFilter   難 ﺪ        捻  
         蝹 ﳊ  ○   ﯼ   ﻍ 難 粒 
ActionBean     ﯲ        ᅪ ﮧ  ﯲ
  ﻱ                ﷓ 﫜   
 ActionBean StripesFilter ﶬ 缾 ﯡ 什  ﯹ   J SP ﻄ
ﳾ 鬒 DispatcherServlet  炙    難   J SP   
 𧻓  indexjsp StripesFilter   ﷪ 﫳 ﯡ  ﷓ ﳸ 
 ¢   J SP     炙   難   ActionBean  
 eventﶫ ￈  StripesFilter     ActionBean
﫳 ﶫ 﫳    捻  ﯡ ﶻ  DispatcherServlet  ﷸ  
DispatcherServlet ﯡ  ﻝ    URL   ﶨ   Ac
tionBeanﶫ HttpservletRequest    﫽   Action
Bean  﫴  紐   﫳   ¢   event    
    什   ﶼ 2 ﯹ 諭 
ﶼ 2 Stri pes 捻    ﶼ
2 Aj ax  Stripes   蝹 ᅱ
Stri pes  Aj ax ﳡ 囹       ﯼ     
 龜   Aj ax ￲ ﳜ ¢  ﯼ ￉  ﲯ  ᅱ   﫜 
Ajax ￲ ﳜ ﯼ ￉  調  Dojo 鬒 DWR    ﳒ 﫬 ᄂ 
Ajax ￲ ﳜ 淋  ￉   ﳲ  ￉   ﷓      
J avaScript  ¬  ﳡ 囹  Aj ax￲ ﳜ ﷡ 𢡊 Stri pes   
ﳘ   ﷪  ﳘ   Ajax  蝹 ᅱ   ᅡ ﶫ  jQuery
  ©  J avaSeript ￲ ﳜ   Stri pes  蝹 ᅱ   Aj ax
  
21 Stripes   Aj ax  
Stri pes   Ajax  ￉   ﺪ     難  
 ﷓  ActionBean  難    ﷓  J SP    
   ﳥ ¢ ﶬ  ﯡ  ﯘ 﫽 ﻝ  ﶬ  難   Action
Bean     ﯘ  﫽 ﻝ  諾  ﳓ    ﮯ ￉  ﺪ
J SON ￳ ￉  ﺪ XML  ￉  ﺪ HTML    難
  J SP        ﯘ J SP     
22 Stripes   Aj ax 諭 
  ﶫ ﯡ ﻙ      缾    ﮧ  ﺨ    
   Stri pes   ﳲ   AJ ax 蝹 ᅱ  諾  ﷓  
    J avaScript ￲ ﳜ 鬒 Stri pes 吝  ﳘ   蝹 ᅱ 
( 1) 𧻓 ￈ ﶨ       ﮧ  ﺨ    Action
Bean  ﳻ ﶼ 3 ﶼ  ￉  ᄡ    J AVA5  
﷢ ﲼ 﫵 ﺪ   Action      Url   Url ﶫ 難
AJ ax    Url  ﶬ 缾  ﶫ    ﮧ  ﺨ     
   ﺪ    輸 ﳾ      難 ﯹ     ﷢ 
Stri pes       淋  ￉   ﶬ   Action 
           ﶼ 3  Action   ﳓ  
QQ鉶 ﺨ   輸 ﳾ      ﶫ    ﺪ  ﶬ  輸
ﳾ ﲴ ￉ 
 1   麟  ﯹ  Stripes￲ ﳜ  Ajax     ﺿ 7 
ﶼ 3   ﺨ   ActionBean
( 2 ) webxml ﻄ ﳾ  ﺪ   ActionBean  
StripesFiher 鬒 DispatcherServlet  ﶼ 4 ﯹ 諭 ﻒ  
 ﶫ  窱 ActionBean     StripesFiher ᅡ ﶬ 缾 ﶫ
Action    URL    StripesDispatcherServl et ᅡ 
        缾 﫲 ﯼ ﶫ  StripesFilter  ﺭ 
      ¢   URL
ﶼ 4 webxml   ﻄ ﳾ
( 3) web    ﯍ AJ ax  
       jQuery ￲ ﳜ   ﯍ Ajax 
 ﻟ ﳥ    ᅡ 
function validateUni queName ( iqancle) {
vat resul t = f al se 
j Query~j ax( {
type  P OST  
url   common user val idate uni queName 
dataTypej son
data{usernamename}
Successfunction (resp) {
if ( respstatus ===OK) {
if ( respcontent ===true) {
alert( ﮧ   ﺭ  !) 
result  false 
}else {
alert(  ﮧ    !) 
result = true 
}
}
}
}) 
retu m result 
 紐      ￉  ᄡ        﫽 鬒
URL ﻍ ￉   ﯍ Ajax     ￉   ﻝ  ﯘ 
﷡ 炙  →      紐        ﻱ    ﯘ
 難   J SON ￳  ﯹ   ᅪ ﮧ      缾 﫲
ﻍ ￉    json   諾  ﷢ ﻶ   
3 Ajax  Stripes  﫽 ﻝ  﫤  諾   
 Stri pes  Aj ax  ﯘ  﫽 ﻝ  諾     ᅡ ﲸ
 J SONXML J avaScript  ﲰ htm1 諾 
31 j sON  XML   ﷏
311 Stripes   J SON
@J SON    ﷢ ﻶ    ﲨ  J SON  ￳ 
﫳 ﲨ  ©  難    ￳      ﮧ  難  ﺨ  
  ﯘ   難   簾  ﲰ ¢ 律  ﳡ 諭  ᄁ    
  ￳   諭      {statusOkmessage

what you want to see}  﫳 ﲨ 難    ￳   ﶫ
   ￳  﫳 ﲨ  ﮻ ﺪ   J SON    﫳  
ﷹ      ﯍           ﷢ ﻶ ﺪ J SON
 ￳ 
@J SON     ﯘ   Stri pes    J SON
     ﯘ 調   難 Stri pes    StreamingReso
lution  ﯼ  ﶫ      﫽 ﻝ  ﯘ      
     J SON     調  ᅡ     ﻍ 
ﶫ J SON     ﯘ  ᅪ ﮧ  
new StreamingResolution( textj soncharset =UTF-
8yourJ sonObject) 
      ﮻ ﺪ J SON  ￳   J SON  
 ﯘ  ᅪ ﮧ  缾 ￉   ﷓ 調  J avaScript   eval 絛
﫽  ﷢ ﻶ ﯼ  難 eval 絛 﫽  缾 ﯡ    →    ﷡
炙   調   難 J query    Aj ax    ﷢ ﻶ
J SON       Aj ax   缾 ﶫ 﫽 ﻝ  data
Type 裡  ﺪ json  ﻍ ￉  ﶫ  ﻱ    ﯘ 

8 ﳆ ﯣ ﯺ ﲼ 﫵     22ﻭ
J SON   ﷢ ﻶ  J SON ￳   ﻍ ￉     調
 J SON ￳  
312 J SON  XML  
 ￉       ﻟ   ﷏   ￉    ￉ 
 紐    ¢  ﻞ ﲸ 
 ￉     XML l1ﻀ  ￉       
J SON ﺪ XML ﳬ 狀 ﻍ ﻟ  ￉    
      XML ﯹ  DOM      
J SON﮵    難 J avaScript     J SON    
ﳓ  ﳲ ﷠   
 ﷢     J SONﻍ 難   J avaScript   ￳ 
  ﯼ  ﷢  ﻍ 難 調   ￳ ﷢    ﲸ 﫵 ﺪ  
XML   ￱ ﷢ ﻶ DOM   ﷢ ﻶ   ﷏  
32 J avaSc~pt 﫽 ﻝ  諾  J SON XML   ﷏
321 Stri pes   J avaScript 﫽 ﻝ  諾
  龜 ﷢ ﻶ   Stripes        ﷐
J avascriptResolution￉  ﶨ 什      J avaS
criptResolution  惡  絛 﫽 惡   J avascriptResolution
 ￳  ﶨ 什 return  ﻤ ﶫ       J avaScript
  諾  ﯘ   return new JavascriptResoluti0n( a
left( hello word!) ) 
  龜  ﮻   調  J query  Ajax ¬    
ﶫ dataType裡  ﺪ scri pt ﻍ ￉   JavaScript  
諾  ﮻ ↓   﫽 ﻝ 
322 J avaScript 﫽 ﻝ  諾   陼
 調  J avaScript       難 ﯼ    﫽 ﻝ
 ﳤ     ﮷ 律 ᄉ  缾 﫲 ﯹ  ᅱ      ﳲ ﷠ 
ﶨ 什 J avaScript   諭   律 ᄉ ﶫ   ﻟ  ￉   鬒
￉    
 律    ﮯ        J avaScript  諾 
﮵ ﯼ ﻍ 難 J avaScript   難 ECMAScript    
4 ﷡ 﫸 
ﻄ         AjaXﲼ 﫵   Stri pes  
  ﲶ  ￲ ﳜ  ﻶ 調  Stri pes+Aj ax ﳜ 惡  ﶬ 缾  ﻶ
  Stripes+Aj axﳜ 惡   﫽 ﻝ  﫤  諾     﫽
ﻝ  﫤  諾     調    ￉       
Stripes+Ajax  ﷢ ﻶ   ￉   ﻝ  ﲺ     
 ﳑ  蝹 ᅱ    ﳡ 囹     ﷝ ﶻ ﮥ   遲 
Web ᆰ   諾    Stripes ﳲ ﲰ     簾  ¢
 ﶫ      Ajax缾 ﶫ ﯡ   Stri pes+Ajax  
 ᄐ ﻄ ᅲ 
[ 1] ﷵ       AJAXWeb20 ᆰ  ﲼ 﫵 ↑ ﷢ [M]
 ﺩ       裏 2005
[2]  ﷲ  ﻢ   ﷵ  ᄐ  ﯹ  Struts ￲ ﳜ  Web  
   蝹 ᅱ [J ] ﳆ ﯣ ﯺ ﲼ 﫵    200616(4) 102
104 
[3]   ﯹ  J 2EE  AJAX ᆰ    [M] ﺩ   捻
   裏 2007
[4] 隆   ﻢ 画  AJ Ax  Struts     [J ]ﳆ ﯣ ﯺ ﲼ 﫵
   200717(10) 6972
[5] ᅡ   AJ AX ᆰ  ﺫ        ￲ ﳜ [M]  ﺩ 
 捻    裏 2006
[6]   磌   ﯹ  Stmt~ ￲ ﳜ  AJ Ax ᆰ   ﺿ [J ]
ﳆ ﯣ ﯺ 捻   裡 ﳆ 200930(16) 39103913
[7] Beginning Stri pes[EBOL ]2007httpwwwstri pesframe
workorg displaystripesHome
[8]    調  Stri pesᆰ  web  [J ]   襁  ﲼ 﫵 
2007( 8) 403404
[9] Bibeaul t BKatz YjQuery 蝹  [ M]    ﺩ 
     裏 2009
[ 10]      Aj ax 諾    ﶻ ﮥ Web ﮷ ﺳ    
[J ]ﳆ ﯣ ﯺ ﲼ 﫵    200616( 10) 228230
[11] 隆   ﷵ   ﯹ  Web20  Ajax ﲼ 﫵  ᆰ  [J ] ﳆ
ﯣ ﯺ ﲼ 﫵    200717(5) 203205
[12] Introducing J SON[EBOL ]2002httpwwwJSONorg
[13] XML[EBOL] 2000httpenwiki pedi aorgwiki
[ 14] Standard ECMA  262 ECMAScript Language Specifi cation
[EBOL]2001httpwwwecma- internati ona1orgpubli
cations standards Ecma - 262htm
( 紐 ﷓  4  )
[2]  狀  ﯆    變 﫬 ﷸ 紐 ᄐ 䀹 ᄉ ﶳ  裡 ﳆ ﲰ 蝹 ᅱ [J ]
ﳆ ﯣ ﯺ 捻  200228(1) 275277
[3] ﻢ 﫪  OFFICE ﻄ   ￳  ﻶ     ﻭ  ﺿ [ D]紐
画 ﮪ  益    2009
[4]   ﷸ ﷰ   ﷸ       ﻭ  蝹 ᅱ   [J ]  ﶭ
益      200730(4) 424427
[5] W3CDocument Object Model (DOM) I~vel 1 Specifi cation
Version 10[EBOL] 1998 httpwwww3org
[6]   ← ﯹ  XML  ﯘ    Web  ᄁ    ﺿ  蝹 ᅱ
[D]  ﺩ  ﺩ ﶻ ﶨ   2009
f7] Shaker MIbrahim HInformation Extraction from Hypertext
MarkUp La nguage Web Pages[ J ] Journ al of Computer Sci
ence20095(8) 596- 607
[8] Laender A H FRibeiro- Neto B AA bri ef survey of web data
extraction tool s[J ]ACM SIGMOD200231(2) 84- 93
[9] Moro M MBraganholo VXML some papers in a haystack
J ] ACM SI GMOD Record Archi ve200938(2) 2934
[1O]   ﻻ HTML  ﮻  XML  諾  ﲰ  ﶬ XML    諾
 ﳤ   ﮻ [D]紐 画 紐 画 ﶻ ﶨ   2003
[ 11] ﳀ ᅨ     Word    ﻭ ᄉ ﶳ  裡 ﳆ  蝹 ᅱ [J ]
ﳆ ﯣ ﯺ 捻     200844(35) 69- 72
[ 12]      ﯹ  ﷸ     ﳆ ﯣ ﯺ ᄐ 䀹 ᄉ ﶳ [J ]ﳆ
ﯣ ﯺ 捻  200127(8) 150152