表单中文问题**

1.表单中文处理步骤**

  step1 

    jsp 文件,要添加
     <%@page pageEncoding="utf-8" contentType="text/html;charset=utf-8"%>
    表单设置 method="post"。
  step2
    在 servlet 类当中,添加 request.setCharacterEncoding("utf-8");
  step3
    如果要访问数据库:
    a. 保证数据库能够正常地保存中文。
     对于 mysql 数据库
     create database dbname default character set utf8;
    b. 使用 jdbc 访问数据库时,必须要保证 jdbc 驱劢程序能够识别数据库中保存数据的编码。

     jdbc:mysql://localhost:3306/数据库名?useUnicode=true&characterEncoding=utf8

posted @ 2014-03-23 19:27  不苦先生  阅读(128)  评论(0编辑  收藏  举报