• 2022-06-12
    阅读下面代码片段:Servlet1:response.setHeader(“Content-Type”,“text/html;charset=utf-8”);response.getOutputStream().write(“疫情”.getBytes(“utf-8”));request.getRequestDispatcher(“/Servlet2”).forward(request,response); Servlet2: response.getOutputStream().write(“防控”.getBytes(“utf-8”));当使用浏览器访问Servlet1时会什么结果
    A: 浏览器输出 “疫情防控”均正常无乱码
    B: 浏览器输出“疫情”为乱码,输出“防控”正常
    C: 浏览器输出“疫情”正常,输出“防控”乱码
    D: 浏览器输出“防控”正常
  • D
    本题目来自[网课答案]本页地址:https://www.wkda.cn/ask/ztxzexppzjytpxo.html

    举一反三

    内容

    • 0

      阅读下面代码片段: Servlet1: request.setAttribute("name", "zhangsan"); RequestDispatcher dispatcher = request.getRequestDispatcher("/ResultServlet"); dispatcher.forward(request, response); response.getWriter().write("over"); Servlet2: response.setContentType("text/html;charset=utf-8"); String name = (String) request.getAttribute("name "); response.getWriter().println("名称:" + name); 先使用浏览器访问Servlet1,然后将Servlet1中的forward()方法更改为include()方法再次访问Servlet1,两者输出情况的描述正确的是(  )。

    • 1

      阅读下面Servlet的doGet()方法中代码片段: A: ring data="中国"; B: sponse.setCharacterEncoding("utf-8"); C: intWriter out = response.getWriter(); D: t.println(data); E: 开浏览器后,点击【查看】à【编码】à【utf-8】选项,再访问时看到的结果,说法正确的是() F: 正常输出:中国 G: 输出乱码 H: H. 出现500异常 I: I. 页面没有任何输出

    • 2

      阅读下面代码片段:Servlet1:response.getWriter().write(“hello,servlet1”);request.getRequestDispatcher().include(“Servlet2”);Servlet2:response.setHeader(“Refresh”,”1”);response.getWriter().write(“,servlet2”); A: 正常显示:hello,servlet1,servlet2 B: 正常显示:hello,servlet1,servlet2,并且页面会不断刷新 C: 正常显示:,servlet2 D: 正常显示:hello,servlet1

    • 3

      阅读下面代码片段: Servlet1: response.getWriter().write(“hello,servlet1”); request.getRequestDispatcher().include(“Servlet2”); Servlet2: response.setHeader(“Refresh”,”1”); response.getWriter().write(“,servlet2”);

    • 4

      下面选项中,用于设置浏览器显示文本采用UTF-8编码的是 A: response.setHeader("Content-Type","charset=utf-8"); B: request.setHeader("Content-Type","charset=utf-8"); C: request.setHeader("Content-Type","text/html;charset=utf-8"); D: response.setHeader("Content-Type","text/html;charset=utf-8");