Window选项下---preferences选项;
打开preferences->General->workspace,设置UTF-8;
同样是preferences->MyEclipse->Files and Editors ->CSS、HTML、JSP、JavaScript、XML设置为ISO 10646/Unicode(UTF-8)。
如果没有配置过上述的设置就创建项目出现乱码情况的,点击项目名,右键找到Properties,检查Text file encoding是否为UTF-8;
类和页面同上,右键找到Properties,检查Text file encoding是否为UTF-8;
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
先检查是否设置,没有请加上,如果有请把它放到最上面(亲身经历,找了好久才发现 T_T)
//服务器安装路径下conf文件夹里的server.xml文件
tomcat/conf/server.xml文件
将相关语句改为:
<Connector port="8008" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8"/>
之前的语句没有URIEncoding="UTF-8"这一句
第一种是修改mysql的my.ini文件中的字符集键值
default-character-set = utf8
character_set_server = utf8
修改完后,重启mysql的服务
还有一种,就是使用mysql的命令
SET character_set_client = utf8 ;
SET character_set_connection = utf8 ;
jdbc.url=jdbc:mysql://localhost:3306/数据库?useUnicode=true&characterEncoding=UTF-8
HttpServletResponse res = ServletActionContext.getResponse();
HttpServletRequest request = ServletActionContext.getRequest();
res.setCharacterEncoding("utf-8");
res.setContentType("text/html;charset=utf-8");
request.setCharacterEncoding("utf-8");
在SSM框架中的注解里加一句话:
produces = "text/html;charset=UTF-8"
例如:@RequestMapping(value="/selectMallByTitle",produces = "text/html;charset=UTF-8")
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。