Struts/ActionのTIPS集
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
#topicpath
----
#contents
**fowardするだけ [#q3d9c061]
まずは基本。フォワードするだけ。
<action-mappings>
<action path="/index"
forward="/WEB-INF/jsp/index.jsp" />
</action-mappings>
と記述しておくことで、
http://hogehoge/[path]/index.do
というURLでindex.jspへアクセス可能となります。直接JSPを指...
**formを定義する [#tc0aa38b]
<form-beans>
<form-bean name="LoginForm"
type="org.apache.struts.validator.DynaValidatorF...
<form-property name="userId" type="java.lang.String"...
<form-property name="pass" type="java.lang.String" />
</form-bean>
</form-beans>
...
<action-mappings>
<action path="/login"
forward="/WEB-INF/jsp/index2.jsp" name="LoginForm"...
</action-mappings>
と記述しておきます。画面(JSP)では
<html:form action="/login" focus="userId" method="post">
<div id="errmsg"><html:errors /></div>
<table border="0" class="center">
<tr>
<td width="20%" align="right">ユーザID</td>
<td align="left"><html:text property="userId"
styleClass="inputStrImeDisabled" size="40" maxle...
tabindex="1" /></td>
</tr>
<tr>
<td width="20%" align="right">パスワード</td>
<td align="left"><html:password property="pass"
styleClass="inputStrImeDisabled" size="42" maxle...
tabindex="2" redisplay="false" /></td>
</tr>
<tr>
<td><br />
</td>
</tr>
<tr>
<td width="20%"></td>
<td align="left">
<html:submit property="loginButton" value="ログイン"
styleClass="fButtons" tabindex="3" /></td>
</tr>
</table>
<html:hidden property="url" />
</html:form>
としておくことで、テキストボックス付きのformになります((...
次はいよいよアクションをかませます。
**アクションを呼び出す [#wfd617f6]
上の定義の
<action path="/login"
forward="/WEB-INF/jsp/index2.jsp" name="LoginForm"...
を
<action path="/login"
type="nu.mine.kino.actions.LoginAction" name="Logi...
<forward name="success" path="/WEB-INF/jsp/index2.js...
</action>
に変更します。すると遷移先がアクションクラスとなり、アク...
package nu.mine.kino.actions;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
public class LoginAction extends Action {
@Override
public ActionForward execute(ActionMapping mapping, Ac...
HttpServletRequest request, HttpServletResponse re...
throws Exception {
// TODO Auto-generated method stub
System.out.println("hogehoge");
return mapping.findForward("success"); <-forward nam...
}
}
書き途中!
**つづき [#vcf1ca16]
Struts/ActionのTIPS集2
----
この記事は
#vote(おもしろかった[26],そうでもない[24]);
#topicpath
SIZE(10){現在のアクセス:&counter;}
終了行:
#topicpath
----
#contents
**fowardするだけ [#q3d9c061]
まずは基本。フォワードするだけ。
<action-mappings>
<action path="/index"
forward="/WEB-INF/jsp/index.jsp" />
</action-mappings>
と記述しておくことで、
http://hogehoge/[path]/index.do
というURLでindex.jspへアクセス可能となります。直接JSPを指...
**formを定義する [#tc0aa38b]
<form-beans>
<form-bean name="LoginForm"
type="org.apache.struts.validator.DynaValidatorF...
<form-property name="userId" type="java.lang.String"...
<form-property name="pass" type="java.lang.String" />
</form-bean>
</form-beans>
...
<action-mappings>
<action path="/login"
forward="/WEB-INF/jsp/index2.jsp" name="LoginForm"...
</action-mappings>
と記述しておきます。画面(JSP)では
<html:form action="/login" focus="userId" method="post">
<div id="errmsg"><html:errors /></div>
<table border="0" class="center">
<tr>
<td width="20%" align="right">ユーザID</td>
<td align="left"><html:text property="userId"
styleClass="inputStrImeDisabled" size="40" maxle...
tabindex="1" /></td>
</tr>
<tr>
<td width="20%" align="right">パスワード</td>
<td align="left"><html:password property="pass"
styleClass="inputStrImeDisabled" size="42" maxle...
tabindex="2" redisplay="false" /></td>
</tr>
<tr>
<td><br />
</td>
</tr>
<tr>
<td width="20%"></td>
<td align="left">
<html:submit property="loginButton" value="ログイン"
styleClass="fButtons" tabindex="3" /></td>
</tr>
</table>
<html:hidden property="url" />
</html:form>
としておくことで、テキストボックス付きのformになります((...
次はいよいよアクションをかませます。
**アクションを呼び出す [#wfd617f6]
上の定義の
<action path="/login"
forward="/WEB-INF/jsp/index2.jsp" name="LoginForm"...
を
<action path="/login"
type="nu.mine.kino.actions.LoginAction" name="Logi...
<forward name="success" path="/WEB-INF/jsp/index2.js...
</action>
に変更します。すると遷移先がアクションクラスとなり、アク...
package nu.mine.kino.actions;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
public class LoginAction extends Action {
@Override
public ActionForward execute(ActionMapping mapping, Ac...
HttpServletRequest request, HttpServletResponse re...
throws Exception {
// TODO Auto-generated method stub
System.out.println("hogehoge");
return mapping.findForward("success"); <-forward nam...
}
}
書き途中!
**つづき [#vcf1ca16]
Struts/ActionのTIPS集2
----
この記事は
#vote(おもしろかった[26],そうでもない[24]);
#topicpath
SIZE(10){現在のアクセス:&counter;}
ページ名: