GVKun编程网logo

Switch to UTF-8 charset in Mysql on Ubuntu 对于Ubuntu的Mysql_MySQL(switch运行ubuntu)

3

本文将为您提供关于SwitchtoUTF-8charsetinMysqlonUbuntu对于Ubuntu的Mysql_MySQL的详细介绍,我们还将为您解释switch运行ubuntu的相关知识,同时

本文将为您提供关于Switch to UTF-8 charset in Mysql on Ubuntu 对于Ubuntu的Mysql_MySQL的详细介绍,我们还将为您解释switch运行ubuntu的相关知识,同时,我们还将为您提供关于、@RequestBody MultiValueMap不支持内容类型'application / x-www-form-urlencoded; charset = UTF-8'、@RequestBody MultiValueMap不支持内容类型'application / x-www-form-urlencoded; charset= UTF-8'的实用信息。

本文目录一览:

Switch to UTF-8 charset in Mysql on Ubuntu 对于Ubuntu的Mysql_MySQL(switch运行ubuntu)

Switch to UTF-8 charset in Mysql on Ubuntu 对于Ubuntu的Mysql_MySQL(switch运行ubuntu)

Ubuntu

对于ubuntu的mysql中, 选择utf-8编码

当在Ubuntu中安装Mysql时, 默认的编码集可能是latin-1. 既然Ubuntu使用UTF-8作为大多数东西的编码集, 这样(latin-1)做就有点奇怪了. 但实际上很容易设置.

Mysql的配置文件/etc/mysql/my.cnf 有神奇的一行:

 

!includedir /etc/mysql/conf.d/
登录后复制

这就使得它包含的设置都位于 conf.d 的子目录下. 不推荐去直接改变 my.cnf文件, 因为它会导致一些问题, 当在升级 Ubuntu/Mysql 到一个新的版本时.

创建一个新文件:/etc/mysql/conf.d/utf8_charset.cnf 有下面这些内容

Mysql 5.1

[mysqld]default-character-set=utf8[client]default-character-set=utf8
登录后复制
Mysql 5.5
登录后复制
[mysqld]<br>character-set-server=utf8<br>collation-server=utf8_general_ci
登录后复制
[client]default-character-set=utf8
登录后复制

重启mysql, 然后你将会拥有UTF-8的编码集:

$ mysql -u root -p -e "show variables like ''%character%''"+--------------------------+----------------------------+| Variable_name| Value|+--------------------------+----------------------------+| character_set_client | utf8 || character_set_connection | utf8 || character_set_database | utf8 || character_set_filesystem | binary || character_set_results| utf8 || character_set_server | utf8 || character_set_system | utf8 || character_sets_dir | /usr/share/mysql/charsets/ |+--------------------------+----------------------------+ 
登录后复制

original url:http://blog.lesc.se/2011/06/switch-to-utf-8-charset-in-mysql-on.html

<meta charset =“ utf-8”>与<meta http-equiv =“ Content-Type”>

为了为 HTML5 Doctype 定义字符集,我应该使用哪种表示法?

  1. 短:

    <meta charset="utf-8" />
  2. 长:

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

答案1

小编典典

在HTML5中,它们是等效的。使用较短的一个,更容易记住和键入。浏览器支持很好,因为它是为向后兼容而设计的。

" alt="">

">

为了定义HTML5 Doctype的字符集,我应该使用哪种表示法?

  1. Short:

html <meta charset="utf-8" />

  1. Long:

html <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

答案1

小编典典

在 HTML5 中,它们是等价的。使用较短的,因为它更容易记住和输入。浏览器支持很好,因为它是为向后兼容而设计的。

@RequestBody MultiValueMap不支持内容类型'application / x-www-form-urlencoded; charset = UTF-8'

@RequestBody MultiValueMap不支持内容类型'application / x-www-form-urlencoded; charset = UTF-8'

我写了下面的@Controller方法

@RequestMapping(value = "/{email}/authenticate", method = RequestMethod.POST            , produces = {"application/json", "application/xml"}            ,  consumes = {"application/x-www-form-urlencoded"}    )     public        @ResponseBody        Representation authenticate(@PathVariable("email") String anEmailAddress,                                    @RequestBody MultiValueMap paramMap)                throws Exception {            if(paramMap == null || paramMap.get("password") == null) {                throw new IllegalArgumentException("Password not provided");            }    }

请求失败并出现以下错误

{  "timestamp": 1447911866786,  "status": 415,  "error": "Unsupported Media Type",  "exception": "org.springframework.web.HttpMediaTypeNotSupportedException",  "message": "Content type ''application/x-www-form-urlencoded;charset=UTF-8'' not supported",  "path": "/users/usermail%40gmail.com/authenticate"}

[PS:泽西岛要友好得多,但鉴于此处的实际限制,现在无法使用它]

答案1

小编典典

问题在于,当我们使用application / x-www-form-urlencoded时,Spring不会将其理解为RequestBody。因此,如果要使用它,则必须删除@RequestBody批注。

然后尝试以下操作:

@RequestMapping(value = "/{email}/authenticate", method = RequestMethod.POST,        consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE,         produces = {MediaType.APPLICATION_ATOM_XML_VALUE, MediaType.APPLICATION_JSON_VALUE})public @ResponseBody  Representation authenticate(@PathVariable("email") String anEmailAddress, MultiValueMap paramMap) throws Exception {   if(paramMap == null && paramMap.get("password") == null) {        throw new IllegalArgumentException("Password not provided");    }    return null;}

@RequestBody MultiValueMap不支持内容类型'application / x-www-form-urlencoded; charset= UTF-8'

@RequestBody MultiValueMap不支持内容类型'application / x-www-form-urlencoded; charset= UTF-8'

基于Spring @Controller对x-www-form-urlencoded的问的答案

我写了下面的@Controller方法

@RequestMapping(value = "/{email}/authenticate", method = RequestMethod.POST            , produces = {"application/json", "application/xml"}            ,  consumes = {"application/x-www-form-urlencoded"}    )     public        @ResponseBody        Representation authenticate(@PathVariable("email") String anEmailAddress,                                    @RequestBody MultiValueMap paramMap)                throws Exception {            if(paramMap == null || paramMap.get("password") == null) {                throw new IllegalArgumentException("Password not provided");            }    }

失败的请求因以下错误

{  "timestamp": 1447911866786,  "status": 415,  "error": "Unsupported Media Type",  "exception": "org.springframework.web.HttpMediaTypeNotSupportedException",  "message": "Content type ''application/x-www-form-urlencoded;charset=UTF-8'' not supported",  "path": "/users/usermail%40gmail.com/authenticate"}

[PS:Jersey要友好得多,但鉴于这里的实际限制,现在无法使用它]

答案1

小编典典

问题在于,当我们使用 application / x-www-form-urlencoded时
,Spring不会将其理解为RequestBody。因此,如果要使用它,则必须删除 @RequestBody 批注。

然后尝试以下操作:

@RequestMapping(value = "/{email}/authenticate", method = RequestMethod.POST,        consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE,         produces = {MediaType.APPLICATION_ATOM_XML_VALUE, MediaType.APPLICATION_JSON_VALUE})public @ResponseBody  Representation authenticate(@PathVariable("email") String anEmailAddress, MultiValueMap paramMap) throws Exception {   if(paramMap == null && paramMap.get("password") == null) {        throw new IllegalArgumentException("Password not provided");    }    return null;}

请注意,删除了注释 @RequestBody

关于Switch to UTF-8 charset in Mysql on Ubuntu 对于Ubuntu的Mysql_MySQLswitch运行ubuntu的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于、@RequestBody MultiValueMap不支持内容类型'application / x-www-form-urlencoded; charset = UTF-8'、@RequestBody MultiValueMap不支持内容类型'application / x-www-form-urlencoded; charset= UTF-8'等相关知识的信息别忘了在本站进行查找喔。

本文标签: