2008å¹´1æ27æ¥ JBoss+Struts2+Velocity ã¦ã£ã¨ãæ©ããã¤ã³ãç³»ãµã¤ããæ§ç¯ããã ãããä»åã®ä¾é ¼ã ã ã¢ã¼ããã¯ãã£ã®é¸æè¢ã¯ãã¤ãé£ããããä»åã¯ããã»ã©æ©ã¾ãªããã³ã¼ãéãããã«æ¸ãããï¼ãèãããèªç¶ã¨ãããªã£ãã struts2ã ãã¯ã¡ãã£ã¨èª¿æ»ããªããã°ãããªãã 1.Struts2 ã¾ãStruts2ã®ãã¼ã¸ããstruts-2.0.11-all.zipããã¦ã³ãã¼ãããã ãµã³ãã«ãå ¥ã£ã¦ãã¯ãã exampleããã¼ã«ã«ç°å¢ã§å®è¡ãã¦å¤§ä½ãã¤ããã ãããå°ã£ããã¨ã«Viewã«Velocityã使ã£ããµã³ãã«ããªããã Velocityã使ã£ãå ´åã®ã¤ã¡ã¼ã¸ã¯ãActionã³ã³ããã¼ã©ã§velocityãã³ãã¬ã¼ããªãã¸ã§ã¯ããæå®ãã¦ãvelocityã³ã³ããã¹ãã«çªã£è¾¼ãã modelã¨ãã¼ã¸ããããããã ãããªã 2.ã¢ããã¼ã·ã§ã³ Str
[Struts2][XWork2] æå®ããããã¼ãã¯åå¨ãã¾ããã http://struts.apache.org/2.x/docs/hello-world.html HTMLããã¬ã¼ã ã¯ã¼ã¯ããéä¿¡ããã¨ããå ¥åã¯ä»ã®ãµã¼ãã¼ãã¼ã¸ã«éä¿¡ãããã®ã§ã¯ãªããããªããæä¾ããJavaã¯ã©ã¹ã«éããã¾ãããããã®ã¯ã©ã¹ã¯Actionã¨å¼ã°ãã¾ããActionã®å®è¡å¾ãResultããã¬ã¹ãã³ã¹ã«æ¸ãåºããªã½ã¼ã¹ãé¸ã³åºãã¾ãããªã½ã¼ã¹ã¯ãé常ã¯ãµã¼ãã¼ãã¼ã¸ã§ãããPDFãã¡ã¤ã«ããExcelãJavaã¢ãã¬ããã®ã¦ã£ã³ãã¦ãé¸æãããã¨ãã§ãã¾ãã åç´ãªã¦ã§ã«ã«ã ã¡ãã»ã¼ã¸ã表示ãã"Hello World"ãä½æãããªãã°ã空ã®"tutorial"Webã¢ããªã±ã¼ã·ã§ã³ã"Hello World"ã¨ãã¦ä½æãã以ä¸ã®ä½æ¥ãè¡ãã¾ãã ã¡ãã»ã¼ã¸ã表示ãããµã¼ãã¼ãã¼ã¸ãä½æ ã¡ãã»ã¼
é·ããã¨æ¾ç½®ãã¦ãã®ã§ã¡ããã¡ããæ¸ãã¦ããã¤ããã ã¯ãã¼ã©ã¼ã¿ãããªãã®ãä½ã£ã¦ãã¨ãã°ããããåºã¦å°ãã ä»æ¥åããããã¤ã¯200MBãè¶ ãã¦ãããããã¦éãããVSCodeãä¸å®å®ã«ãªã£ãã åèµ·åããããã®ã¡ãã»ã¼ã¸ããããä»ã¾ã§æ£ã Pythonã§ã³ã¼ãæ¸ãã¦ããããªããä½å¿ãã¦ãã®ã ãã°ã¯è¦ãããåºåéã¯æ¸ãããã ãã°ãåºãããåé¡ã¸ã®å¯¾å¦ã®åºæ¬ã¯ããã±ã¼ã¸åä½ã§åºåãã°ã¬ãã«ãä¸ãããã¨ã ãã©ãã¯ãã¼ã©ã¼ã®ãããªãç¸æå´ã®ãã¼ã¿ã®é½åã§ãã¡ãã®å¦çã®æå¦ã決ã¾ããããªããã°ã©ã ã¯åºåã¬ãã«ãä¸ããã¨ã¨ã©ã¼ãè¦ã¦ãããããªããã¨ãå¤ããå¿ ãå ¥ãæ³å®ï¼ä¾ãã°ãã¥ã¼ã¹è¨äºã®ã¿ã¤ãã«ï¼ã®XPathã®çµæãNoneãªã®ã¯ãªãï¼ã¿ãããªã®ã¯ãUnitTestã§å åããã¦å質ãä¸ããã®ãé£ããã ãããªãã¨ãããç¨åº¦ãã£ããã¨ããæ³å®ã§ä½ã£ãããã°ã©ã ã«å¦çã®éä¸çµéã®ãã°ãDEBUG
ãã¼ãã«ã¿ã¤ãã£ã¦ä½ããããï¼ ãã¼ã¿ã®æã¡æ¹ã§ãå é¨çã«ä½ããéãã¨ãããã¨ãªãã§ããããã ã°ã°ã£ã¦ãåºã¦ãããããã£ããã¨æ¬ã§èªã¾ãªãããã¡ã ãªã£ã¨ã ããããæè¡æ å ±ã¯èª¿ã¹ãæéããããã°ã©ãã ãã§ããããã§ããã å®éã«æ¥åãã£ã¦ã£ã¨ãã¨ããããçµè«ã ãç¥ãããã¢ã¿ãªãã¤ãã¦é²ããããã©ã£ã¡ãã§ãã£ã±ããã£ã±ããªãã ãã¾ãå°éã«ç©ã¿éãããããªãããªã ç°¡åã«ã¯ããã¤ã³ãã¸ã£ã¼ãã«ã«è¼ã£ã¦ãããèªåã®åããç¯å²ã§æãåºãã¨ã MyISAMã¯ã ã»ããã©ã«ãã®ãã¼ãã«ã¿ã¤ã ã»é«éã«åä½ ã»ãã«ããã¹ãæ¤ç´¢ã«å¯¾å¿ ã»ãã©ã³ã¶ã¯ã·ã§ã³ãå¤é¨ãã¼å¶ç´ã®ãµãã¼ããªã ã»ããã¯ã¯ãã¼ãã«ã¬ãã« InnoDBã¯ã ã»ãã©ã³ã¶ã¯ã·ã§ã³ããµãã¼ã ã»å¤é¨ãã¼å¶ç´ããµãã¼ã ã»ã¯ã©ãã·ã¥æã®ãªã«ããªã«å¯¾å¿ ã»åã¬ãã«ã§ããã¯ãå®æ½ ã»ãã«ããã¹ãæ¤ç´¢ãã§ããªã 以ä¸ãè¦ã¦ã¿ãã¨ãã¢ããªã®ç¨éã«ãã£
æ®ã£ã¦ãã¦æãä»ãã¦ããªãã¨ããã¯ä»¥ä¸ã®3ç¹ã§ãã ç»é²æã®ãã¿ã³ï¼åº¦æ¼ãã¸ã®å¯¾å¿ sessionã¿ã¤ã ã¢ã¦ãã«ãªã£ãã¨ãã®Mapã«ä¿åããã¦ããæ¤ç´¢çµæãªã¹ãã®åé¤ ãã©ã¦ã¶ããããªãéããã¨ãã®Mapã«ä¿åããã¦ããæ¤ç´¢çµæãªã¹ãã®åé¤ ãã®ãã¡ãå¤æ´ç¹ã説æãããã¨æã£ã¦ãã¾ãã ãã®ãµã³ãã«ã®ã½ã¼ã¹ã欲ããæ¹ã¯ funky_maji@hotmail.com ã¾ã§ã¡ã¼ã«ããã ãããEclipseã®ããã¸ã§ã¯ãã¨ãã¦ã¡ã¼ã«ã§éãã¾ãã
Eclipseãå ¥ãã¦ãSubversionããã½ã¼ã¹ããã§ãã¯ã¢ã¦ããã¦ãã¢ããªã±ã¼ã·ã§ã³ãµã¼ãã Runãã¦ãåä½ãè¦ãªãã JSPãæ¸ãæãã¦ããã HTMLã©ã¤ã¿ã¼ãããªãã¦æ°ããã»ã©ããããªãã®ã ããä¸ã®ä¸ã«ã¯ï¼ ã¨ãããã㧠Struts2ã®ç»é¢è¡¨ç¤ºãããã«ããã£ã¦ JSPã®ãããã« Mayaa ã使ãæ¹æ³ã調ã¹ãã Mayaaãç§ã®ç解ãã¦ããç¯å²ã§ç°¡åã«èª¬æããã¨ãIEã Firefoxã§ãã®ã¾ã¾è¡¨ç¤ºã§ãã¦ãã¾ããããªããæ®éã® HTMLãã¡ã¤ã«ãä¸æè°ã¨åçãªãã¼ã¸ã®è¡¨ç¤ºã«ä½¿ãã¦ãã¾ããã³ãã¬ã¼ãã¨ã³ã¸ã³ï¼åçè¦ç´ ã®å®ç¾©ã¯HTMLãã¡ã¤ã«ã®é£ã« mayaaãã¡ã¤ã«ã¨ãã¦é ç½®ããï¼ã¨ãããã¨ããããããã 㨠HTMLã©ã¤ã¿ã¼ã¨ããã°ã©ãã®åæ¥ãæ®´ãåããçºçããã¹ã ã¼ãºã«ããï¼ãããããªãï¼ã¨ããããã ã¨ã¯ãã Mayaaã«ã¤ãã¦ããã»ã©æ·±ãç¥ããªãã®ã§ãããã§ã¯Stru
ããæ°æ¥ãè¨è¨æ¸æ¸ãã¦ãããã§ã³ã¼ãã£ã³ã°ããé ããã£ã¦ãã¾ããããåéãããã¸ã§ã¯ãèªä½æµããããªé°å²æ°ã§ããï¼ãï¼ ããã©ã¯ãæçµçã«å®è·µçãªã¢ããä½ããããªâã«å£ã£ã¦ãåå¼·ã http://www15.plala.or.jp/k_maeba/struts2/hello/index.html æé ã«å¾ã£ã¦æ§æãã¦ãã㨠(1) ããã¡ã¤ã«ãâãæ°è¦ãâãã¯ã©ã¹ããé¸æããJavaã¯ã©ã¹ããã¤ã¢ãã°ã表示ãã¾ãã (2) ã¹ã¼ãã¼ã¯ã©ã¹ã®æ¨ªã«ãããåç §...ããæ¼ä¸ãã¦ãåã«ãActionSupportããå ¥åããActionSupportãã¯ã©ã¹ãé¸æãã¾ãã ç¶ãã¦ãååãã«ãHelloãã¨å ¥åãã¦ããçµäºããæ¼ä¸ãã¾ãã ã»ã»ã»ã»ã»ã»ã»é¸æã§ãã¾ããï¼æ±) ãã£ã¨ã°ã°ã£ã¦ã¿ã¦ããStruts2ã§ã¯æ®éã«ActionSupport使ãããã§ããçãªãã®ããåºã¦ããªãã®ã§ãã²ã¨ã¾ãææ¸
ã¾ããæåã«è¨ã£ã¦ããã¹ããã¨ã§ãããç§ã¯ãã®ãStruts2ãã£ã¦ããã®ãæ£ç´è¦æã§ãã ä»äºã§ä½¿ããã¨ã«ãªãã¾ãã¦ãä»æ¹ãªã使ã£ã¦ã¾ããããªãã¨ããããã¾ãçæ§ã®æ¹ããåãã§ããããã åºæ¬çã«æ å ±ãå°ãªããã§ãããããããã¯ã¾ã£ã¦ãã¾ã£ãæã®ã¤ã©ã¤ã©æãå端ããããã¾ãããã¯ãã ã§ãåãã¦ã¨ãªãè¨äºãªãã§ããããã®ã¯ã¾ã£ã¦ãã¾ã£ããã®ãã²ã¨ã¤ãç´¹ä»ã ãã ãä»åç§ããããã¨ãæ£ãããã¨ãªã®ãå¦ããæ£ç´ããããã¾ãããã¯ãã ãã§ãä»åã¯ã¾ã£ããã¤ãªãã§ãããconversionErrorã ã¡ãªã¿ã«ç°å¢ã¯Struts2+Seasarã ã¾ãç¾è±¡ã ããã¹ãããã¯ã¹ã®ãã£ã¼ã«ãã®åãintãªããã«ãã¦ãæ°å¤ãããªãå¤ãå ¥åãã¦sendããã¨ã å ¥åã¨ã©ã¼ã«ã¯ãªããã ãã©ããã®å¾ã©ã®ã¢ã¯ã·ã§ã³ãåããªããªãã¨ããç¾è±¡ãçºçã ãããã°ã§å¦çã追ã£ã¦ãã¢ã¯ã·ã§ã³å ã§è½ã¡ã¦ããããã§ããªã
struts2.0 ã¯ä»¥å struts1 ãããã£ãç¨åº¦ã®èº«ã«ã¯å®ã«ç°¡åã§ãã ã¾ããBean ãå±±ã»ã©ä½ãå¿ è¦ãç¡ããã«ãã´ãªæ¯ã«ã¯ã©ã¹ãä½ã£ã¦ã¾ã¨ãããã¾ãã struts.xml ã沢山æ¸ãå¿ è¦ãããã¾ãããstruts1 ã® 1/10 ç¨åº¦ã§ã¯ãªããã¨æãã¾ãã ããæ¹æ¬¡ç¬¬ã§ã¯ struts.xml ãå ¨ãæ¸ããªãäºãåºæ¥ãããã§ãããå®é¨ç®ç以å¤ã§ã¯èéãå©ããªããªãã ãã§ããããããstruts.xml ã¯æ¸ããæ¹ãããã§ãããã struts2 㯠WEB ãæ¤ç´¢ãã¦ãæç®ãå°ãªãæããããä¸ãæ¸ç±ãæ¬å±ã§è¦ãããªãæ°ããã¾ãããJAVA ã§ã¦ã§ããµã¤ããæ§ç¯ããå ´åã¯ä¸»æµã«ãªãããã§ãããã®ã§ãç¥ã£ã¦ãã¦æã¯ç¡ãã¨æãã¾ãã åæºåã®ä¸ã¤ã§ãããstruts.properties ãã¡ã¤ã«ã®æ¬¡ã®è¡ã§ãã±ã¼ã«ã¨æåã³ã¼ããæå®ãã¦ããªãã¨ãæååããèµ·ããå ´åãããã¾ãã
Javaã«ã¤ãã¦ãã¾ã詳ãããªãã£ãã®ã§ããã¬ã¼ã ã¯ã¼ã¯ã¨è¨èªåå¼·ãããã¦Struts2 + hibernateã§ãåå¼·ç¨Webã¢ããªãå¶ä½ãã¦ãã¾ããããªããªãè¨èªã®ããæ£ç´æããã£ã¦ãã¾ã(C/Perlã®æ¹ãç°¡åã»ã») ã§Javaã¨ããã°æ°ã«ãªãã®ãã¹ã¬ããã»ã¼ã(thread safe)ãä»è¨èªã§ã®ã¹ã¬ããã»ã¼ãã®ä½ãæ¹ã¯ãããã®ã§ãå ±ç¨å¤æ°ã«ã¹ãã¼ã¿ã¹ãæãããçãè¡ããªããã°ã¹ã¬ããã»ã¼ãã«ãªããã¨ã¯ãããã®ã§ãããStruts2ã®ãµã³ãã«ããã°ã©ã ãè¦ã¦ãã¦çåã«æã£ããã¨ãã import com.opensymphony.xwork2.ActionSupport; public class indexAction extends ActionSupport { public String execute() throws Exception { return "succes
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}