当前位置:网站首页>JSP out.print()和out.write()方法的不同之处
JSP out.print()和out.write()方法的不同之处
2022-08-02 00:01:00 【qq_25073223】
转自:
JSP out.print()和out.write()方法的不同之处
下文讲述out.print()和out.write()方法的区别,如下所示:
out.print()和out.write()方法简介
JSP中out.print()和out.write()方法 都属于抽象类Writer的抽象子类JspWriter的方法; 其中out.print()方法属于抽象子类JspWriter中的方法, 而out.write()是父类Writer的方法. ------------------------------------------------- out.print():调用的是JspWriter类中的方法 out.writer():调用的是其父类Writer类中的方法
两个方法的不同之处:
1.print方法是子类JspWriter,write是Writer类中定义的方法 2.重载的print方法可将各种类型的数据转换成字符串的形式输出,而重载的write方法只能输出字符、字符数组和字符串等与字符相关的数据 JspWriter类型的out对象使用print方法和write方法都可以输出字符串 3.如果字符串对象的值为null时,print方法将输出内容为“null”的字符串 而write方法则是抛出NullPointerException异常
例
输出数字
<% out.print(98); %> <hr/> <% out.write(98); %> -----运行以上代码,将输出不同的信息--- 98 ----------------- b
边栏推荐
- 正则表达式
- Share an interface test project (very worth practicing)
- 检查 Oracle 版本的 7 种方法
- 洞见云原生微服务及微服务架构浅析
- Appears in oozie on CDH's hue, error submitting Coordinator My Schedule
- Docker实践经验:Docker 上部署 mysql8 主从复制
- 信息系统项目管理师必背核心考点(五十七)知识管理工具
- 根本上解决mysql启动失败问题Job for mysqld.service failed because the control process exited with error code
- @WebServlet注解(Servlet注解)
- 使用 Zadig 交付云原生微服务应用
猜你喜欢
随机推荐
Thinkphp 5.0.24变量覆盖漏洞导致RCE分析
不就是个TCC分布式事务,有那么难吗?
图解LeetCode——1161. 最大层内元素和(难度:中等)
Axure教程-新手入门基础(小白强烈推荐!!!)
2022 6th Strong Net Cup Part WP
【三子棋】C语言实现简易三子棋
ICLR 2022 Best Paper: Partial Label Learning Based on Contrastive Disambiguation
OpenCV DNN blogFromImage() detailed explanation
Chrome书签插件,让你实现高效整理
@Scheduled注解详解
Use Jenkins for continuous integration, this knowledge point must be mastered
@Resource和@Autowired的区别
ansible模块--copy模块
2022还想上岸学习软件测试必看,测试老鸟的肺腑之言...
[头条]笔试题——最小栈
windows sql server 如何卸载干净?
【解决】win10下emqx启动报错Unable to load emulator DLL、node.db_role = EMQX_NODE__DB_ROLE = core
SphereEx Miao Liyao: Database Mesh R&D Practice under Cloud Native Architecture
检查 Oracle 版本的 7 种方法
background-image使用