用chrome 和 IE都试过(也把编码换成 UTF-8),网址输入为 : http://localhost:8080/mydoodling/info?username=张动态生成的网页内容为: 你好寮?请问中文代码到底是哪个?获取浏览器表单参数的代码为:public class ServletInfo extends HttpServlet { public void doGet ( HttpServletRequest req , HttpServletResponse resp) throws IOException { String username = req . getParameter ( "username") ; if (null != username) { username = new String ( username.getBytes ( "ISO-8859-1") , "GB2312") ; } resp . setContentType ( "text/html;charset=GB2312") ; PrintWriter out = resp . getWriter ( ) ; out . println ("<html><body>"+"你好" + username+"</body></html>") ; out . close ( ) ; } }
添加回答
举报
0/150
提交
取消