• 01_6_SERVLET如何从上一个页面取得参数


    01_6_SERVLET如何从上一个页面取得参数

    1. sevlet实现

    public void doGet(HttpServletRequest request, HttpServletResponse response)

    throws ServletException, IOException {

    //处理从客户端获取的参数 此方法只针对客户端post方法

    //request.setCharacterEncoding("utf-8");

    //获取客户端传过来的参数

    String parameter1 = null;

    String parameter2 = null;

    String parameter3 = null;

    parameter1 = request.getParameter("parameter1");

    parameter2 = request.getParameter("parameter2");

    parameter3 = request.getParameter("parameter3");

    parameter1 = new String(parameter1.getBytes("iso-8859-1"), "utf-8");

    parameter2 = new String(parameter2.getBytes("iso-8859-1"), "utf-8");

    parameter3 = new String(parameter3.getBytes("iso-8859-1"), "utf-8");

    //处理与何种格式回复客户端

    response.setContentType("text/html; charset=utf-8");

    PrintWriter out = response.getWriter();

    out.println("<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">");

    out.println("<HTML>");

    out.println("  <HEAD><TITLE>A Servlet</TITLE></HEAD>");

    out.println("  <BODY>");

    out.print("    This is ");

    out.print("TreeParameter Servlet");

    out.print("<br/>");

    out.print("第一个参数为:");

    out.println(parameter1);

    out.print("<br/>");

    out.print("第二个参数为:");

    out.println(parameter2);

    out.print("<br/>");

    out.print("第三个参数为:");

    out.println(parameter3);

    out.print("<br/>");

    out.println("  </BODY>");

    out.println("</HTML>");

    out.flush();

    out.close();

    }

  • 相关阅读:
    js学习笔记
    Bootstrap学习笔记
    css学习任务二:切图写代码
    九宫格改进
    js学习笔记
    XHTML复习笔记
    html基础知识复习笔记
    css学习任务一:绘制九宫格
    如何不使用第三个变量来交换两个数的值
    算术右移与逻辑右移
  • 原文地址:https://www.cnblogs.com/flyback/p/8681845.html
Copyright © 2020-2023  润新知