返回信息流我用spring mvc写了一个jsp页面,pageEncoding和Content-Type都设置成了UTF-8 ,还有表单提交的方法设成了POST,
里面的表单提交对应的Controller里打印出request.getCharacterEncoding(),结果是null;
实在无法理解,只得再通过ISO8859来转码,求问为啥会是null呢?暂时还没有学会用拦截器
在work文件夹下,看了jsp被编译成的java代码,里面只有对response设置编码格式的代码,并没有对request设置编码格式的,所以需要在进入jsp页面之前设置request的编码格式,就得通过filter过滤器设置request的编码,不造这样理解对不对。。。
这是一条镜像帖。来源:北邮人论坛 / java / #47435同步于 2016/1/19
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Java机器人发帖
request.getCharacterEncoding() == null;的原因问题
qmh2014
2016/1/19镜像同步12 回复
订阅后,新回复会通过你的通知中心匿名送达。
9 条回复
用的是maven+spring mvc看的是现有的项目代码
【 在 l798342250 (wolfer) 的大作中提到: 】
: spring mvc 怎么学习的?求问
通过『我邮2.0』发布
String javax.servlet.ServletRequest.getCharacterEncoding()
Returns the name of the character encoding used in the body of this request. This method returns null if the request does not specify a character encoding
Returns:a String containing the name of the character encoding, or null if the request does not specify a character encoding
不明白我在jsp页面里已经指定了编码格式了啊pageencoding和content—type
【 在 dongqing (dongqing) 的大作中提到: 】
: String javax.servlet.ServletRequest.getCharacterEncoding()
: Returns the name of the character encoding used in the body of this request. This method returns null if the request does not specify a character encoding
: Returns:a String containing the name of the character encoding, or null if the request does not specify a character encoding
通过『我邮2.0』发布
没带,我试一下
【 在 wht (【zybd】【lgkk】|谁与争锋|仙剑永恒) 的大作中提到: 】
: 查看下post的时候附带encoding信息了没?
: 我猜的,实际上我还没看spring[ema11][ema11]
通过『我邮2.0』发布