回覆列表
  • 1 # 匠工加工

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    // TODO Auto-generated method stub

    request.setCharacterEncoding("UTF-8");

    request.setAttribute("username", "dhweicheng");

    request.setAttribute("password", "123456");

    request.getRequestDispatcher("/my.jsp").forward(request, response);

    }

    <%@ 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>頁面程式碼</title>

    </head>

    <body>

    <h5>透過request物件取值</h5>

    賬號:<%=request.getAttribute("username") %>

    密碼:<%=request.getAttribute("password") %>

    <P>=======================</P>

    <h5>透過EL表示式取值</h5>

    賬號:${username}

    密碼:${password}

    </body>

    </html>

  • 中秋節和大豐收的關聯?
  • thefingerfamily什麼意思?