有什么方法在html或者代码中进行字符编码格式转换? 具体怎么做? ```html <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title></title> </head> <body> <form action="/login" method="post"> 用户名:<input type="text" name="username"> 密码:<input type="password" name="password"> <input type="submit" value="登陆"> </form> </body> </html> ``` 这是utf-8格式的html文件。 ```go func login(w http.ResponseWriter, r *http.Request) { fmt.Println("method:", r.Method) //获取请求的方法 if r.Method == "GET" { t, _ := template.ParseFiles("D:/gopath/src/myworkspace/login.gtpl") t.Execute(w, nil) } else { //请求的是登陆数据,那么执行登陆的逻辑判断 fmt.Println("username:", r.Form["username"]) fmt.Println("password:", r.Form["password"]) } } ``` 这是login界面,如何不处理,网页就是显示乱码?
有疑问加站长微信联系(非本文作者)
