【IT168技术文档】
从form表单提交信息到一个JSP页面或者一个Servlet进行处理的时候,提交的中文信息若不加处理的话就会显示乱码,如一串???。现在通过一个例子来进行总结如下:
写一个用户信息提交页面,通过这个页面向一个JSP页面或者一个servlet提交用户信息,代码如下:
Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ 1<%@ page language="java" contentType="text/html; charset=gbk"%> 2<html> 3 <head> 4 <title>表单提交</title> 5 </head> 6 <body> 7 <form action="deal.jsp" method="post"> 8 用户名:<input type="text" name="username"><br> 9 密 码:<input type="password" name="password"><br> 10 爱 好:<input type="radio" name="love" value="运动">运动 11 <input type="radio" name="love" value="音乐">音乐<br> 12 <input type="submit" value="提交"> 13 </form> 14 </body> 15</html>
现在写deal处理页面,代码如下:
Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ 1<%@ page language="java" contentType="text/html; charset=gbk"%> 2<html> 3 <head> 4 <title>显示用户信息</title> 5 </head> 6 <body>
您可能感兴趣的文章
评论总数:
条[ 查看全部 ] 网友评论

RSS订阅




