首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

mysql中文乱码有关问题,命令方式正确,MySQL Maestro工具正确,jsp页面异常,mysql-front异常

2012-02-15 
mysql中文乱码问题,命令方式正确,MySQL Maestro工具正确,jsp页面错误,mysql-front错误mysql乱码问题,请求

mysql中文乱码问题,命令方式正确,MySQL Maestro工具正确,jsp页面错误,mysql-front错误
mysql乱码问题,   请求解决方法
全部是utf8编码.
命令方式查询,先执行set   names   'latin1 ',然后正确,不执行set   names   'latin1 ',出现乱码....

MySQL   Maestro工具查询正确,

jsp页面查询乱码
但是用new   String(rs.getString(1).getBytes( "iso_8859_1 "), "gbk ")转换后就正确了.....

mysql-front查询,乱码............

请求大家给个方法...弄了一晚上没弄出来........

[解决办法]
装MYSQL的时候字符集选GB2312啊
[解决办法]
全部是utf8编码.

装mysql时也是要utf8的。
[解决办法]
在mysql里建表的时候加上 ENGINE=MyISAM DEFAULT CHARSET=utf8
CREATE TABLE `depart` (
`id` int(5) NOT NULL auto_increment,
PRIMARY KEY (`id`),
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=0 ;
[解决办法]
你可以把mysql 的配置文件改了.
把他的编码改成gbk 或者 gb2312
然后重新启动服务. 这样不会有MYSQL 的中文问题了.
[解决办法]
编码格式统一就OK了

jsp页面改成utf-8
数据库整理改成utf-8
源码文件也改成utf-8



[解决办法]
界面,数据库,jsp的代码都要编码一致,实在有问题用强制转换
[解决办法]
我感觉如果是数据库里面也是乱码的话,就从你往数据库里面写数据的地方找.
[解决办法]
1、建议mysql使用gbk编码!
C:\WINNT> type my.ini
[mysqld]
basedir=D:/mysql
datadir=D:/mysql-data/data
default-character-set=gbk

[client]
default-character-set=gbk

2 连接mysql的时候,使用这样的url就能够搞定了!
String url = "jdbc:mysql://localhost:3306/sunnywest?useUnicode=true&characterEncoding=gbk ";
String user = "root ";
String password = "dada ";
Connection connRemoteMysql = DriverManager.getConnection(url, user, password);

[解决办法]
编码格式统一就OK了 ,但我建议还都是统一用utf-8编码!!!!!!!



希望能帮到你!!!!!

[解决办法]
mysql-front 设置成utf-8或GBK 中文的。。。
连库也指定编码。。。
jdbc:mysql://127.0.0.1:3306/authdb?useUnicode=true&characterEncoding=gb2312
[解决办法]
设置一个过滤器,
web.xml加
<filter>
<filter-name> SetCharacterEncodingFilter </filter-name>
<filter-class> com.hotpepper.util.SetCharacterEncodingFilter </filter-class>
<init-param>
<param-name> encoding </param-name>
<param-value> UTF-8 </param-value>
</init-param>
<init-param>
<param-name> ignore </param-name>
<param-value> true </param-value>
</init-param>
</filter>

<filter-mapping>
<filter-name> SetCharacterEncodingFilter </filter-name>
<url-pattern> /* </url-pattern>
</filter-mapping>


public class SetCharacterEncodingFilter
implements Filter {

// ----------------------------------------------------- Instance Variables




/**
* The default character encoding to set for requests that pass through
* this filter.
*/
protected String encoding = null;

/**
* The filter configuration object we are associated with. If this value
* is null, this filter instance is not currently configured.
*/
protected FilterConfig filterConfig = null;

// --------------------- Public Methods


/**
* Take this filter out of service.
*/
public void destroy() {

this.encoding = null;
this.filterConfig = null;

}

/**
* Select and set (if specified) the character encoding to be used to
* interpret request parameters for this request.
*
* @param request The servlet request we are processing
* @param result The servlet response we are creating
* @param chain The filter chain we are processing
*
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet error occurs
*/
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {


String encoding = selectEncoding(request);

if (encoding != null) {
request.setCharacterEncoding(encoding);
} else {
request.setCharacterEncoding(encoding);
}
response.setContentType( "text/html;charset=UTF-8 ");
// Pass control on to the next filter
chain.doFilter(request, response);


}

/**
* Place this filter into service.
*
* @param filterConfig The filter configuration object
*/
public void init(FilterConfig filterConfig) throws ServletException {

this.filterConfig = filterConfig;
this.encoding = filterConfig.getInitParameter( "encoding ");

}

// ------------------------------------------------------ Protected Methods


/**
* Select an appropriate character encoding to be used, based on the
* characteristics of the current request and/or filter initialization
* parameters. If no character encoding should be set, return
* <code> null </code> .
* <p>
* The default implementation unconditionally returns the value configured
* by the <strong> encoding </strong> initialization parameter for this
* filter.
*
* @param request The servlet request we are processing
*/
protected String selectEncoding(ServletRequest request) {

return (this.encoding);

}

}

热点排行