木叶威化
2016-05-22 10:18
<%@ page="" language="java" import="java.util.*" contenttype="text/html; charset=utf-8">不是已经设置编码了吗?为什么还会乱码?要用request.setCharacterEncoding("utf-8"); ?
当前页面设置编码了,对直接在页面内容中的字符有效。但是对于从别的页面接受的数据还需要设置编码方式。
不好意思,有点误解最佳答案的意思了。其实也就是jsp容器在接收到request的时候,并不会去检查发出请求的页面的编码。
和是不是别的页面其实没关系。不信你用login.asp自己接收表单,效果也是一样。原因官方解释了:“Currently, many browsers do not send a request encoding qualifier with the Content-Type header. In such cases, a web container will use the default encoding, ISO-8859-1, to parse request data.”
JAVA遇见HTML——JSP篇
248279 学习 · 3119 问题
相似问题