问答详情
源自:7-4 forward动作

有个问题,之前讲过忘了?

<%@ page="" language="java" import="java.util.*" contenttype="text/html; charset=utf-8">不是已经设置编码了吗?为什么还会乱码?要用request.setCharacterEncoding("utf-8");   ?

提问者:木叶威化 2016-05-22 10:18

个回答

  • hyaline
    2016-05-22 10:56:46
    已采纳

    当前页面设置编码了,对直接在页面内容中的字符有效。但是对于从别的页面接受的数据还需要设置编码方式。

  • qq_幸福客_0
    2017-02-20 09:57:52

    不好意思,有点误解最佳答案的意思了。其实也就是jsp容器在接收到request的时候,并不会去检查发出请求的页面的编码。

  • qq_幸福客_0
    2017-02-20 09:15:07

    和是不是别的页面其实没关系。不信你用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.”