服務(wù)器:Tomcat 7.0.xx
在Servlet的doGet方法中添加以下代碼:
創(chuàng)新互聯(lián)公司專業(yè)為企業(yè)提供吉林網(wǎng)站建設(shè)、吉林做網(wǎng)站、吉林網(wǎng)站設(shè)計(jì)、吉林網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)與制作、吉林企業(yè)網(wǎng)站模板建站服務(wù),十載吉林做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。
String str = request.getParameter("username");
byte[] bytes = str.getBytes("iso-8859-1");
str = new String(bytes, "utf-8");
例子:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String str = request.getParameter("username");
byte[] bytes = str.getBytes("iso-8859-1");
str = new String(bytes, "utf-8");
System.out.println(str);
}
當(dāng)服務(wù)器:Tomcat 8.0.xx時(shí),不需要輸入 以上代碼,可以直接輸出
例子:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String str = request.getParameter("username");
System.out.println(str);
}