回覆列表
  • 1 # 使用者834195712159

    jsp獲取下拉框元件的值

    1.首先,寫一個帶有下拉框的前臺頁

    <%@ page language="java" contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

    <html>

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <title>Insert title here</title>

    </head>

    <body>

    <form action="request3.jsp" method="post">

    來自的國家<br/>

    <select name="country">

    <option value="中國">中國</option>

    <option value="美國">美國</option>

    <option value="俄羅斯">俄羅斯</option>

    </select>

    <br/>

    <input type="submit" />

    </form>

    </body>

    </html>

    2.寫一個處理頁獲取下拉框元件的值

    <%@ page language="java" contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

    <html>

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <title>Insert title here</title>

    </head>

    <body>

    <%

    request.setCharacterEncoding("utf-8");

    String national = request.getParameter("country");

    out.println(national);

    %>

    </body>

    </html>

  • 中秋節和大豐收的關聯?
  • 老人手抖正常嗎?