1. 程式人生 > >Servlet中文顯示問號解決方法

Servlet中文顯示問號解決方法

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		response.setContentType("text/html;charset=gb2312");////在PrintWriter前面有效果
		PrintWriter out = response.getWriter();
		request.setCharacterEncoding("utf-8");
	   // response.setContentType("text/html;charset=gb2312");////在PrintWriter後面無效果
		
		 userId1 = request.getParameter("userId1");// ///需要2個引數
		userId2 = request.getParameter("userId2");


一定要注意語句的順序!!!!