String 変数 = request.getParameter( 名前 );
※リストが表示されない場合
AddBlockなどの広告ブロックツールがONになっているとリストなどが表示されない場合があります。これらのツールをOFFにしてみてください。
※index.htmlのリスト <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Hello App Engine</title> <style> h1 { font-size: 16pt; background: #AAFFAA; padding: 5px; } </style> </head> <body> <h1>Hello App Engine!</h1> <p id="msg">※なにか書いて送信してください。</p> <form method="post" action="/mygaeapp"> <table> <tr> <td>入力</td> <td><input type="text" id="input" name="text1"></td> </tr> <tr> <td></td> <td> <input type="submit" value="送信する"> </td> </tr> </table> </form> </body> </html> ※MyGaeAppServletサーブレットのリスト package com.tuyano.libro.mygaeapp; import java.io.*; import javax.servlet.http.*; @SuppressWarnings("serial") public class MyGaeAppServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("text/plain"); request.setCharacterEncoding("utf8"); response.setCharacterEncoding("utf8"); PrintWriter out = response.getWriter(); out.println("Hello, world!"); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("text/html"); request.setCharacterEncoding("utf8"); response.setCharacterEncoding("utf8"); String param = request.getParameter("text1"); PrintWriter out = response.getWriter(); out.println("<html><head></head><body>"); out.println("<h1>result</h1>"); out.println("<p>you typed: " + param + ".</p>"); out.println("</body></html>"); } }
次へ >> |