@634

JSP

Advertisement

paramアクション

書式
<jsp:param name="パラメータ名" value="値" />
パラメータを他ファイルに渡す。

paramアクションの利用

メイン (param.jsp)
<%@ page contentType="text/html; charset=Shift_JIS" %>
<meta http-equiv="Content-Type" content="text/html;charset=Shift_JIS">

<html lang="ja">
<head>
<title>テスト</title>
</head>
<body>

<%
    String data = request.getParameter("submit");
    String name = request.getParameter("name");
    String age = request.getParameter("age");

    if(data != null){
%>
        <jsp:forward page="param2.jsp">
            <jsp:param name="name" value="<%= name %>" />
            <jsp:param name="age" value="<%= age %>" />
        </jsp:forward>
<%
    }
%>

<form method="post" action="./param.jsp">
NAME<br>
<input type="textbox" name="name"><br>
<br>
AGE<br>
<input type="textbox" name="age"><br>
<br>
<input type="submit" name="submit" value="送信">
</form>

</body>
</html>
param2.jsp
<%@ page contentType="text/html; charset=Shift_JIS" %>
<meta http-equiv="Content-Type" content="text/html;charset=Shift_JIS">

<html lang="ja">
<head>
<title>テスト</title>
</head>
<body>

<%
    String name = request.getParameter("name");
    String age = request.getParameter("age");
%>

<h1>受け取ったパラメータ</h1>
<p>
NAME:<%= name %><br>
AGE:<%= age %>
</p>

</body>
</html>

Advertisement

ショートカット

634
634ブログ
このカテゴリのトップページに戻る
Incubator(Pukiwiki)
634ラボ
   UIコレクションギャラリー
   ZO-3ジェネレーター

サイト検索


Y!ログール