jsp内置对象入门(3) request对象详解【02】2013-07-06关于request对象的方法有很多,在jsp内置对象【03】request详解【01】中,我们一起学习了request对象中的参数接受问题,那么现在再来看一下request的其他方法:乱码解决( setCharacterEncoding())乱码可是WEB开发中的问题老大哥了,我相信有不少接触过这个东西的人都对其相当的头疼。什么是乱码?在运行程序的时候,本来应该显示的中文竟然变成了莫名其妙的其他看不懂的字符,那我们说就碰到乱码了。我们以下面的程序为例:
Request_01.jsp<%@ page language="java" contentType="text/html" pageEncoding="gbk" %> <html> <head> <title>web开发</title> </head> <body> <form action="request_02.jsp" method="post"> 请输入信息:<input type="text" name="info"> <input type="submit" value="提交"> </form> </body> </html> Request_02.jsp <%@ page language="java" contentType="text/html" pageEncoding="gbk" %> <html> <head> <title>web开发</title> </head> <body> <%String content=request.getParameter("info"); %> <h2><%=content%></h2></body> </html>