用servlet來得到。透過request物件的getParameter()方法來獲取。
前端的jsp頁面:
<body>
<form action="/requestDemo" method="post">
<input type="text" placeholder="請輸入使用者名稱" name="username"><br> </form>
</body>
後臺的java程式碼:
@WebServlet("/requestDemo")
public class RequestDemo extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//post 獲取請求引數
//根據引數名稱獲取引數值
String username = request.getParameter("username");
System.out.println("post");
System.out.println(username);
}
用servlet來得到。透過request物件的getParameter()方法來獲取。
前端的jsp頁面:
<body>
<form action="/requestDemo" method="post">
<input type="text" placeholder="請輸入使用者名稱" name="username"><br> </form>
</body>
後臺的java程式碼:
@WebServlet("/requestDemo")
public class RequestDemo extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//post 獲取請求引數
//根據引數名稱獲取引數值
String username = request.getParameter("username");
System.out.println("post");
System.out.println(username);
}