Servlet+JDBC+MySQL乱码
通过Get方式提交参数,url:
http://localhost:8080/Minisite/light?nick="aaa"&mobile=""&prov="江西"&city="景德镇"&game="对对碰"
Servlet里面的doGet代码:
String nick = new String(req.getParameter("nick").getBytes("ISO-8859-1"),"UTF-8"); String mobile = new String(req.getParameter("mobile").getBytes("ISO-8859-1"),"UTF-8"); String prov = new String(req.getParameter("prov").getBytes("ISO-8859-1"),"UTF-8"); String city = new String(req.getParameter("city").getBytes("ISO-8859-1"),"UTF-8"); String game = new String(req.getParameter("game").getBytes("ISO-8859-1"),"UTF-8"); LightMap lm = new LightMap(); lm.insertLightRecord(nick, prov, city, game, mobile);String mobile = new String(req.getParameter("mobile").getBytes("ISO-8859-1"),"GBK");