1. 程式人生 > >http請求引數??的問題

http請求引數??的問題

如題,A專案帶引數傳送請求到B專案。剛開始還好,但是發覺 引數帶中文 就出現問題了,變成了??

解決方法:傳送中文引數前先做處理

request.getSession().removeAttribute("pass");
request.getSession().removeAttribute("type");
//設定編碼格式不然會亂碼??
username = URLEncoder.encode(username,"UTF-8");
address = URLEncoder.encode(address,"UTF-8");
return "redirect:"+resource.getString("business.type.twoURL")+"?price="+price+"&u="+ username+"&d="+address+"&t="+phone;

另一個專案接收,就是普通的接收
String userName =request.getParameter("u");
String address = request.getParameter("d");
String phoneNum = request.getParameter("t");