WAP中传中文参数

[入库:2005年8月18日] [更新:2007年3月25日]

本文简介:选择自 bon_jovi 的 blog

具体分两种情况:一种是在首页设置<input>,让用户输入中文,在第二页接受。另外一种是直接在首页通过参数传中文,然后在第二页接受。

1.第一种情况:first.jsp

    <input name="address" type="text" emptyok="false" size="50"/>
     <br/>
 <anchor><%=waputil.str2utf("提交")%>
  <go href="<%=request.getcontextpath()%>/inputaction" method="get">
      <postfield name="address" value="$(address)"/>
  </go>   
 </anchor>    

second.jsp

      request.setcharacterencoding("utf-8");
     string address = request.getparameter("address");

2.第二种情况:

string sendmsg="中文";
<anchor title="<%=waputil.str2utf("确定")%>">
<go href="sendrest.jsp" method="get">
              <postfield name="sendmsg" value="<%=java.net.urlencoder.encode(sendmsg)%>" />
           </go><%=waputil.str2utf("发送")%>
        </anchor><br/>

接收页面:
string sendmsg = request.getparameter("sendmsg");
if(sendmsg!=null) sendmsg = java.net.urldecoder.decode(sendmsg);
system.out.println("sendmsg:"+sendmsg);

结果:
sendmsg:中文

本文关键:WAP中传中文参数
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top