博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
JSF 2 outputText example
阅读量:6242 次
发布时间:2019-06-22

本文共 1677 字,大约阅读时间需要 5 分钟。

In JSF 2.0 web application, “h:outputText” tag is the most common used tag to display plain text, and it doesn’t generate any extra HTML elements. See example…

1. Managed Bean

A managed bean, provide some text for demonstration.

import javax.faces.bean.ManagedBean;import javax.faces.bean.SessionScoped;@ManagedBean(name="user")@SessionScopedpublic class UserBean{    public String text = "This is Text!";    public String htmlInput = "";        //getter and setter methods...}

2. View Page

Page with few “h:outputText” tags example.

JSF…

JSF 2.0 h:outputText Example

  1. #{user.text}

Generate following HTML code…

             

JSF 2.0 h:outputText Example

  1. This is Text!
  2. This is Text!
  3. This is Text!

For case 1 and 2

In JSF 2.0, you don’t really need to use “h:outputText” tag, since you can achieve the same thing with direct value expression “#{user.text}”.

For case 3

If any of “styleClass”, “style”, “dir” or “lang” attributes are present, render the text and wrap it with “span” element.

For case 4 and 5

The “escape” attribute in “h:outputText” tag, is used to convert sensitive HTML and XML markup to the corresponds valid HTML character.

For example,

< convert to <        > convert to >        & convert to &

By default, “escape” attribute is set to true.

3. Demo

URL : http://localhost:8080/JavaServerFaces/

jsf2-outputtext-example

转载于:https://www.cnblogs.com/ghgyj/p/4765391.html

你可能感兴趣的文章
常用CSS记录
查看>>
我的友情链接
查看>>
DNS介绍和原理
查看>>
使用JIRA搭建企业问题跟踪系统3
查看>>
如何定位消耗CPU最多的线程
查看>>
Linux PAM 之cracklib模块
查看>>
buffer && cache
查看>>
Mockito
查看>>
android闹钟实现原理
查看>>
lamp
查看>>
2-12 Linux一些基础练习的实战资料整理
查看>>
在线图片处理的开源项目或开放平台
查看>>
移动设备硬件统计
查看>>
CoreData
查看>>
【step by step构建轻量级web框架】轻量级框架jbeer预览
查看>>
Spring2.5整合ActiveMQ 5.2
查看>>
浅析Struts1和Struts2的Action线程安全问题
查看>>
java-颠倒一个句子中的词的顺序。比如: I am a student颠倒后变成:student a am I
查看>>
HDU 2017
查看>>
yaml文件java的实现
查看>>