在JSF2中如何避免将#{class.value}视为来自Managed Bean的值检索?

时间:2012-07-29 13:17:05

标签: java jsf xhtml javabeans

I have a bean class as "UserBean" and it has an bean value as "name"
/**** UserBean bean class****/
@ManagedBean
@RequestScoped
public class UserBean {
    private String name;  

    public UserBean() {
    }

   //getter and setter for name
}

now in XHTML file (using JSF2 tags) when i am writing this 
<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core">

<h:head>
    <title>UseBean as Plain Text</title>
</h:head>
<h:body>
    <h:form>
<h1> hello its me #UserBean.name </h:form></h:body></html>

在浏览器中它检索名称字段的值,但我不希望这发生。     我想要的只是在浏览器页面中有一个纯文本,即“你好我#UserBean.name”

怎么做?

1 个答案:

答案 0 :(得分:0)

使用&#34; \&#34;和<outputtext>代码

我这样做了 - <h:outputText value="hello - \#\{userBean.name}" escape="false" />