使用jsp内置对象request获取表单提交中文内容乱码的解决办法
page1.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>page1</title>
</head>
<body>
<form action="page1_1.jsp" method="post">
<input type="text" name="username" />
<input type="password" name="userpwd" />
<input type="submit" value="提交" />
</form>
</body>
</html>
page1_1.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>page1_1</title>
</head>
<body>
<%
request.setCharacterEncoding("utf-8");
String username = request.getParameter("username");
String userpwd = request.getParameter("userpwd");
out.println("username:" + username + "<br/>");
out.println("userpwd:" + userpwd + "<br/>");
%>
</body>
</html>
从page1.jsp页面提交表单到page1_1.jsp页面,注意看page1_1.jsp标红的内容,设置request编码方式为utf-8可以防止获取表单数据为中文时乱码
使用jsp内置对象request获取表单提交中文内容乱码的解决办法的更多相关文章
- Java Web开发总结(三) —— request接收表单提交中文参数乱码问题
1.以POST方式提交表单中文参数的乱码问题 <%@ page language="java" import="java.util.*" pageEnco ...
- JavaWeb——JSP内置对象request,response,重定向与转发 学习总结
什么是JSP内置对象 九大内置对象 requestJSP内置对象 request对象常用方法 request练习 responseJSP内置对象 response练习 response与request ...
- JSP内置对象-request
JSP内置对象即无需声明就可以直接使用的对象实例,在实际的开发过程中,比较常用的JSP对象有request,response,session,out和application等,笔者在本文章中将简单介绍 ...
- JSP内置对象---request对象(用户登录页面(返回值和数组:gerParameter,getParameterValues))
创建两个jsp页面:reg.jsp 和 request.jsp reg.jsp: <%@ page language="java" import="java.uti ...
- JSP内置对象---request 对象
request.jsp: <%@ page language="java" import="java.util.*" contentType=" ...
- JSP内置对象--request对象
本文主要介绍JSP中的request对象 request对象的主要方法: setAttribute(String name,Object):设置名字为name的request的参数值 getAttri ...
- JSP内置对象--request对象 (setCharacterEncoding("GBK"),getParameter(),getParameterValues(),getParameterNames(),getServletPath(),getContextPath()
使用最多,主要用来接收客户端发送而来的请求信息,他是javax.servlet.http.HttpServletRequest接口的实例化对象. public interface HttpServle ...
- form表单提交后结果乱码的解决方法
1.产生乱码原因:表单提交使用的method="get",get方式数据都是通过地址栏传输,数据会以iso-8859-1方式传输,因此产生乱码 2.概念:URI: Uniform ...
- JSP内置对象——request对象
request对象request对象封装了由客户端生成的HTTP请求的所有细节,主要包括HTTP头信息.系统信息.请求方式和请求参数等. 通过request对象提供的各种方法可以处理客户端浏览器提交的 ...
随机推荐
- 这里包含几乎所有的xcode正式版本
https://developer.apple.com/downloads/
- ASP.NET Web API中展示实体Link相关的方面
有时候,向服务端请求一个实体,我们希望返回如下的格式: links: [ href: http://localhost:8901/api/user/diaries/2013-08-17, ...
- 一个简单例子理解C#的协变和逆变
关于协变逆变,SolidMango的解释是比较可取的.有了协变,比如,在需要返回IEnumerable<object>类型的时候,可以使用IEnmerable<string>来 ...
- (Delphi) Using the Disk Cache 使用磁盘缓存
The Chilkat Spider component has disk caching capabilities. To setup a disk cache, create a new dire ...
- IIS 调用Microsoft.Office.Interop.Word.Documents.Open 返回为null
控制面板->管理工具->组件服务->计算机->我的电脑->DCom配置->找到Microsoft Word文档 之后 单击属性打开此应用程序的属性对话框. 2. 单 ...
- mysql time zone时区的错误解决
错误提示: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zon ...
- MyBatis-Generator最佳实践
引用地址:http://arccode.net/2015/02/07/MyBatis-Generator%E6%9C%80%E4%BD%B3%E5%AE%9E%E8%B7%B5/ 最近使用MyBati ...
- 为python安装matplotlib模块
matplotlib是python中强大的画图模块. 首先确保已经安装python,然后用pip来安装matplotlib模块. 进入到cmd窗口下,执行python -m pip install - ...
- 女子监狱第四季/全集Orange Is the New Black迅雷下载
女子监狱 第三季 Orange Is the New Black 3 (2015) 本季看点:该剧由<吉尔莫女孩>.<单身毒妈第一季>编剧杰姬·科恩的打造.由<护士当家& ...
- ios成长之每日一遍(day 5)
iOS 屏幕方向那点事儿http://zhenby.com/blog/2013/08/20/talk-ios-orientation/ 针对当前的屏幕方向进行对应的代码布局 BIDViewContro ...