SAStruts Plugin
id:wyukawaããã®SAStruts Pluginã®éçºéå§ã®ãç¥ããã
Javaã½ã¼ã¹ããJSPãã¡ã¤ã«ã¸ãããã¢ããã¡ãã¥ã¼ãã·ã§ã¼ãã«ãããã¼ã§é£ã¹ãã
ãã¨ãã°ããã¥ã¼ããªã¢ã«ã®tutorial.action.AddActionã§ãã®ãadd.jspããé¸æããã¨ãwebapp/add/add.jspã«é£ã¶ã
@Execute(input = "add.jsp")
public String submit() {
result = Integer.valueOf(arg1) + Integer.valueOf(arg2);
return "add.jsp";
}
Doltengã®HTMLã¨Pageã¯ã©ã¹ãè¡ãæ¥ããæ©è½ã¯ãã¨ã¦ã便å©ãªã®ã§ã
ãããSAStrutsã§ã§ããããã«ãªãã¨ããããã§ããã
å¾ã/xxx/yyy.jspããXxxActionã¯ã©ã¹yyy()ã¡ã½ããã«é£ã¹ãã¨ããããããã
ãªã¹ãã§ã¡ã½ãããé¸ã¹ãã£ã¦ã®ã§ãã便å©ããã
ã¹ã¯ãªããã¬ããããã·ã³ã°ã®æ代ã«ãºãããã«å¼ãè£ãããStrutsã¨ãã°ã³ã°ã³æé·ããRails
ã¹ã¯ãªããã¬ããããã·ã³ã°ã®çå¹éªã®ä¸ã«ããã®ã¯ãStruts(JSP)ã ãã§ã¯ãªãã
Rails(eRuby)ããããããã¦Railsã¯ãããã·ã³ã°ããããæããã
éé
·ãªæ代ã ã£ãã
ã¹ã¯ãªããã¬ããã§ãã¡ã³ãä¸è½ã«ãªã£ãJSPããä¸éã«ããµãããã¨ã§ãéçºè ã¯ãJSPãä¿¡ç¨ããªããªããHTMLãã¼ã¹ã®ãã³ãã¬ã¼ãã¨ã³ã¸ã³ããã¦ã¯ããããã
åé¡ã¯ãã¹ã¯ãªããã¬ããã«ä½ã§ããã¸ãã¯ãæ¸ãã¦ãã¾ãã¨ãããéçºè ã®å§¿å¢ãªã®ã«ããªãããã¿ããªãJSPã¾ã§å¦å®ãã¦ãã¾ã£ãã
ã¤ã¾ãããã®JSPã¸ã®é度ãªããã·ã³ã°ã¯ãåãªãä¸éã§ã¯ãªã人ç½ã ã£ãã
ã誰ã®è²¬ä»»ã§ããªããã¨ããã®ã¯åã ã
ãã®æ¨åã®è²¬ä»»ãè² ãã¹ã人ãã¡ã¯ããããã«ããã
Javaã®ä¸çãä¾å¤ã§ã¯ãªãã£ãã
å©ãããã®ãæ¿ç¥ã§æ£ç´ã«åç½ããã¨ãã¼ãã¯ããã¤ãããã«JSPã¯ä½¿ããã«ãHTMLãã¼ã¹ã®ãã³ãã¬ã¼ãã¨ã³ã¸ã³ãéçºãã¦ãããåã®HTMLãã³ãã¬ã¼ãã¨ã³ã¸ã³ã«å¯¾ãããã¦ãã¦ã¯ã°ã³ã°ã³ä¼¸ã³ã¦ãã£ããããã«æ¯ä¾ãã¦ãã¯ã¶ããã®ä½éãè¥ã太ã£ãã
Railsãè¦é ããããã交ãããã
ãã¹ã¦Rubyã§è¨è¿°ãããã¨ããããã¨ãªãã ã¨ããæ¹éãæã¡åºããã¨ã§ã
ã¹ã¯ãªããã¬ãããåã«å¤ãã¦ãã¾ã£ãã
ããããã4å¹´ããã£ããHTMLãã¼ã¹ã®ãã³ãã¬ã¼ãã¨ã³ã¸ã³ã®ãã¦ãã¦ããã¾ãããã®é·æãçæãè¦ããããã«ãªã£ã¦ããã
ä»ããæãã¨ãJSPã¯éå°ã«ããã·ã³ã°ããã¦ããããã®åå ã®ä¸ç«¯ã¯ãã»ããªãã¬ç§èªèº«ã«ããã
ããããªHTML(Viewãã³ãã¬ã¼ã)ããéè¦ã ã¨ããæ°æã¡ã¯ãä»ãå¤ãããªãããã ããããããªHTMLãã³ã¹ããçããã¨ãååã«ç解ã§ããã
ã³ã¹ãã¨ããã®ã¯ãTeedaã«ãããè¦ç´ã ã£ãããä»ã®ãã¬ã¼ã ã¯ã¼ã¯ã«ãããViewç¨ã®è¨å®ãã¡ã¤ã«ãªã©ã ã
ä»ã®ç§ãããªããã°ãããªããã¨ã¯ãHTMLãã¼ã¹ã®ãã³ãã¬ã¼ãã¨ã³ã¸ã³ã®ã¡ãªããã»ãã¡ãªããããã¡ãã¨æããã«ãã¦ã人ã
ãé¸æããéã®æ
å ±ãå¢ãããã¨ã ããã
ã¾ããJSPã«å¯¾ãã誤解ããã¡ãã¨è§£ããã¨ã ããã
JSPã¯ãããããªHTMLããããã»ã©éè¦ã§ãªãå±é¢ã§ã¯ãå¤åä¸çªããé¸æè¢ã ã¨æãã
ELããã¡ã³ã¯ã·ã§ã³ãçµã¿åãããã¨ããããæ軽ã«ãµã¼ããµã¤ãã®æ
å ±ãViewã®ä¸ã«åãè¾¼ãããããã©ã¼ãã³ã¹ã¯è¯ãããããã¨ãªãã°ãã¹ã¯ãªããã¬ããããããã
ã¹ã¯ãªããã¬ããã¯JSPã«ç´æ¥è¨è¿°ã§ããæ軽ãªãã¡ã³ã¯ã·ã§ã³ã¨ãã¦ä½¿ãã°ãJSPãã¹ãã²ãã£ã¼ã«ãªãå±éºã¯å°ãªãã
ä¸è¨ã®ã¨ã³ããªãåèã«ãªãã¨æãã
<%
public static <T> T getComponent(final Class<T> componentClass) {
return (T) SingletonS2Container.getComponent(componentClass);
}
%>
<%
for (Employee e : getComponent(EmployeeAction.class).empItems) {
out.println(e.name);
}
%>
追è¨:ããã·ã³ã°ãããªãã¦ãããã·ã³ã°ã§ãããä¿®æ£ãã¾ããã
追è¨2:ã¹ã¯ãªãã¬ãããããªãã¦ãã¹ã¯ãªããã¬ããã§ãããä¿®æ£ãã¾ããã
ãªã¼ãã³ã½ã¼ã¹ã§å°åæ å ±ãã©ãããã©ã¼ã ã«æºæ ããèªæ²»ä½åãåºç¤ã
ãªã¼ãã³ã½ã¼ã¹ã§å°åæ å ±ãã©ãããã©ã¼ã ã«æºæ ããèªæ²»ä½åãåºç¤ã
Seasar2ããã¬ã¼ã ã¯ã¼ã¯é¨åãæä¾ãã¦ããã¼ã¹ã