Servlet中的PrintWriter对象 [英] PrintWriter Object in Servlets

查看:251
本文介绍了Servlet中的PrintWriter对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我们使用控制台编写时,通过 System 类访问 out 对象 但是在使用servlet时,使用了printWriter对象而不是 PrintStream 类对象?

When we use Console writing then out object is accessed through System class but while using servlets printWriter object is used instead of PrintStream Class object?

推荐答案

为什么写控制台和Web浏览器之间会有区别

Why because there is difference between writing to console and a web browser

已将编写器附加到响应对象

返回一个PrintWriter对象,该对象可以将字符文本发送到客户端. PrintWriter使用getCharacterEncoding()返回的字符编码.如果未按照getCharacterEncoding中的说明指定响应的字符编码(即该方法仅返回默认值ISO-8859-1),则getWriter会将其更新为ISO-8859-1.

Returns a PrintWriter object that can send character text to the client. The PrintWriter uses the character encoding returned by getCharacterEncoding(). If the response's character encoding has not been specified as described in getCharacterEncoding (i.e., the method just returns the default value ISO-8859-1), getWriter updates it to ISO-8859-1.

由于附加的系统writer不能正确执行Unicode字符转换.

Where as the Systems out attached writer does not do Unicode character conversions correctly.

这篇关于Servlet中的PrintWriter对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆