以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  post的值有中文都是乱码  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=101078)

--  作者:ap9709130
--  发布时间:2017/5/24 16:12:00
--  post的值有中文都是乱码
这个要怎么解决?
--  作者:有点蓝
--  发布时间:2017/5/24 16:40:00
--  
参考:http://www.foxtable.com/mobilehelp/scr/0022.htm
--  作者:ap9709130
--  发布时间:2017/5/24 16:46:00
--  
老师

我的代码里有加这句代码,我的控件是用代码生成,在手机上显示的是中文,但是提交表单时,在服务器上收到的postvalue就是乱码!

--  作者:有点色
--  发布时间:2017/5/24 17:20:00
--  
以下是引用ap9709130在2017/5/24 16:46:00的发言:
老师

我的代码里有加这句代码,我的控件是用代码生成,在手机上显示的是中文,但是提交表单时,在服务器上收到的postvalue就是乱码!

 

你代码里面,是不是做了乱码的处理?

 

使用浏览器测试你的网页。单独做一个网页提交,看提交的值是什么。还有问题做实例发上来。


--  作者:ap9709130
--  发布时间:2017/5/31 16:15:00
--  
试了几天都是乱码。老师帮我看一下:代码如下:
try
    If  e.host = "127.0.0.1" Then
        Dim fl As String
        fl = "D:\\web\\" & e.path
        If filesys.FileExists(fl)
            Dim idx As Integer = fl.LastIndexOf(".")
            Dim ext As String = fl.SubString(idx)
            Select Case ext
                Case ".jpg",".gif",".png",".bmp",".wmf",".js",".css" ,".html",".htm",".zip",".rar"
                    e.Resp
                    e.WriteFile(fl)
                    Return \'这里必须返回
            End Select
        End If
        Dim sb As New StringBuilder
        sb.AppendLine("<!doctype html>")
        sb.AppendLine("<html>")
        sb.appendLine("<head>")
        sb.AppendLine("<meta charset=\'gb2312\'>")
        sb.AppendLine("<meta name=\'viewport\' c>")
        sb.appendLine("</head>")
        sb.AppendLine("<body>")
        Dim wb As New weui
        e.Resp
        Select Case e.path
            Case "test.htm"
                Functions.Execute("test",e)
        End Select
        sb.AppendLine("</body>")
        sb.AppendLine("</html>")
    End If
catch ex As exception
End try


--  作者:ap9709130
--  发布时间:2017/5/31 16:16:00
--  
test 函数就是帮助里面的如下:
Dim e As RequestEventArgs = args(0)
e.Resp 
If e.PostValues.Count = 0 Then
    Dim sb As New StringBuilder
    sb.AppendLine("<form action=\'test.htm?id=1&page=10\' enctype=\'multipart/form-data\' method=\'post\' id=\'form1\' name=\'form1\'>")
    sb.AppendLine("产品: <input name=\'cp\' id=\'cp\'><br/><br/>")
    sb.AppendLine("客户: <input name=\'kh\' id=\'kh\'><br/><br/>")
    sb.AppendLine("雇员: <input name=\'gy\' id=\'gy\'><br/><br/>")
    sb.AppendLine("单价: <input type=\'number\' name=\'dj\' id=\'dj\'><br/><br/>")
    sb.AppendLine("折扣: <input type=\'number\' name=\'zk\' id=\'zk\' min=\'0\' max=\'0.15\' step=\'0.01\'><br/><br/>")
    sb.AppendLine("数量: <input type=\'number\' name=\'sl\' id=\'sl\'><br/><br/>")
    sb.AppendLine("日期: <input type=\'date\' name=\'rq\' id=\'rq\'><br/><br/>")
    sb.AppendLine("<input Type=\'submit\' name=\'Sumbit\' id=\'Sumbit\' value=\'确定\'>")
    sb.AppendLine("</form>")
    e.WriteString(sb.ToString)
Else
    Dim sb As New StringBuilder
    sb.AppendLine("通过GET方式提交的数据:<br/><br/>")
    For Each key As String In e.GetValues.Keys
        sb.AppendLine(key & ":" & e.GetValues(key) & "<br/>")
    Next
    sb.AppendLine("<br/><br/>通过POST方式提交的数据:<br/><br/>")
    For Each key As String In e.PostValues.Keys
        sb.AppendLine(key & ":" & e.PostValues(key) & "<br/>")
    Next
    e.WriteString(sb.ToString)
End If

--  作者:ap9709130
--  发布时间:2017/5/31 16:19:00
--  
只要有中文就是乱码?不管是get 还是Post
--  作者:有点色
--  发布时间:2017/5/31 16:27:00
--  

 字符,应该使用utf-8格式

 

        e.ResponseEncoding = "utf-8"