当前位置:编程学习 > JS >>

servlet解决中文乱编的问题

1. 解决中文乱编的问题
要求1:自行编写程序测试通过表单参数传递引起中文乱码的情况,并解决中文乱编的问题.
(1) 当提交的方式是POST时,应该如何处理?
(2) 当提交的方式是GET时,应该如何处理?
要求2:编写Servlet程序,在Servlet页面中通过PrintWriter输出中文,解决此种乱码情况.

\


 


[html] <%@ page language="java" import="java.util.*" pageEncoding="GBK"%> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html> 
    <head> 
    </head> 
 
    <body> 
        <center> 
            <h1> 
                解决中文乱编的问题 
            </h1> 
            <form action="check" method="get"> 
                <table border="1"> 
                    <tr> 
                        <td colspan="2"> 
                            <h2> 
                                Get提交方式 
                            </h2> 
                        </td> 
                    </tr> 
                    <tr> 
                        <td> 
                            文本: 
                        </td> 
                        <td> 
                            <input type="text" name="username"> 
                        </td> 
                    </tr> 
                    <tr> 
                        <td colspan="2"> 
                            <input type="submit" value="提交"> 
                        </td> 
                    </tr> 
                </table> 
            </form> 
 
            <form action="check" method="post"> 
                <table border="1"> 
                    <tr> 
                        <td colspan="2"> 
                            <h2> 
                                Post提交方式 
                            </h2> 
                        </td> 
                    </tr> 
                    <tr> 
                        <td> 
                            文本: 
                        </td> 
                        <td> 
                            <input type="text" name="username"> 
                        </td> 
                    </tr> 
 
           

补充:Web开发 , Jsp ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,