Servlet中通过request.getParameter()方法提取客户端通过post方式提交的数据时出现中文乱码,可以通过以下哪个方法解决?( )
A: request.setCharacterEncoding("iso-8859-1");
B: request.setCharacterEncoding("utf-8");
C: response.setCharacterEncoding("iso-8859-1");
D: response.setCharacterEncoding("utf-8");
A: request.setCharacterEncoding("iso-8859-1");
B: request.setCharacterEncoding("utf-8");
C: response.setCharacterEncoding("iso-8859-1");
D: response.setCharacterEncoding("utf-8");
举一反三
- 用户使用POST方式提交的数据中存在汉字(使用utf-8字符集),在Servlet中需要使用下述______语句处理。 A: response.setCharacterEncoding("utf-8"); B: request.setCharacterEncoding("utf-8); C: response.setContentType("text/html;charset=utf-8"); D: request.setContentType("text/html;charset=utf-8");
- 在JSP中,假设表单的method="post",在发送请求时,对于中文乱码处理的正确做法是( ) A: request.setCharacterEncoding("utf-8"); B: response.setCharacter("utf-8"); C: request.setContentType("text/html;charset=utf-8"); D: response.setContentType("text/html;charset=utf-8");
- Servlet中通过request.getParameter()方法提取客户端通过post方式提交的数据时出现中文乱码,可以通过以下哪个方法解决?( ) A: request.setCharacterEncoding("iso-8859-1"); B: request.setCharacterEncoding("utf-8"); C: response.setCharacterEncoding("iso-8859-1"); D: response.setCharacterEncoding("utf-8");
- 下面选项中,用于设置浏览器显示文本采用UTF-8编码的是 ( ) A: response.setHeader("Content-Type","text/html;charset=utf-8"); B: request.setHeader("Content-Type","text/html;charset=utf-8"); C: response.setHeader("Content-Type"," charset=utf-8"); D: request.setHeader("Content-Type"," charset=utf-8");
- 下面关于设置编码格式得语法正确的是()。 A: <meta charset="UTF-8"> B: <meta charset="UTF-8" http-equiv="Content-Type"content="text/html;charset="UTF-8"/> C: 以上都错误 D: <meta http-equiv="Content-Type" content="text/html; charset="UTF-8"/>