1.在建立的 WEB 工程中建立 convert.jsp 文件。源代码如下:
<%@ page contentType="text/html;charset=gb2312"%>
<%!
public String codeToString(String str)
{//处理中文字符串的函数
String s=str;
try
{
byte tempB[]=s.getBytes("ISO-8859-1");
s=new String(tempB);
return s;
}
catch(Exception e)
{
return s;
}
}
%>
<% if(request.getParameter("username")==null) out.println("您没有输入姓名。"); else out.println("您输入的姓名为:"+codeToString(request.getParameter("username"))); %>
2.部署并浏览该页面。



