zoukankan      html  css  js  c++  java
  • 如何解决表单提交的中文乱码问题

    a、设置页面编码,若是jsp页面,需编写代码<%@page language="java" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" %>
    若 是 html 页 面 , 在 网 页 头 部 ( < head>< /head> ) 中 添 加 下 面 这 段 代 码 < meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    b 、 将 form 表 单 提 交 方 式 变 为 post 方 式 , 即 添 加 method="post"; ) 在 Servlet 类 中 编 写 代 码request.setCharacterEncoding("UTF-8"),而且必须写在第一行。
    c 、 如 果 是 get 请 求 , 在 Servlet 类 中 编 写 代 码 byte [] bytes = str.getBytes("iso-8859-1");String cstr = new String(bytes,"utf-8");
    或者直接修改Tomcat服务器配置文件server.xml增加内容:URIEncoding="utf-8"

  • 相关阅读:
    1033.采药1
    G——胜利大逃亡 (BFS)
    POJ 3278 Catch That Cow
    C
    11.17 dfs poj1979 Red and Black
    11.11反思
    kmp笔记
    dfs bfs
    1113
    python 类方法
  • 原文地址:https://www.cnblogs.com/Sorry-/p/14135431.html
Copyright © 2011-2022 走看看