如何在单独的行中显示输出文本
How to show output text in separate lines
我的托管 bean 中有两个 String
属性以及相应的 getter 和 setter。
@ManagedBean
@SessionScoped
public class EditorBean implements Serializable {
private String value="hello how are you";
private String message="hello how are you";
public EditorBean() {
value="hello how are you guys?";
message="dd";
}
// ...
}
我想在不同的行中呈现两个字符串。
<h:outputText value="#{editorBean.message}" />
<h:outputText value="#{editorBean.value}" />
但它们显示在一行中。
ddhello how are you guys?
这是怎么引起的,我该如何解决?
你的程序没有问题我测试了你的程序,我得到了这样的结果:
所以它向您展示了这一点,因为您已经更改了构造函数中的值:
public EditorBean() {
value="hello how are you guys?";
message="dd";
}
所以你应该 ddhello how are you guys?
----------------------^--------^
所以如果你想展示:
private String value="hello how are you";
private String message="hello how are you";
你不应该在你的构造函数中再次初始化它们。
备注
试试看到底发生了什么:
Message = <h:outputText value="#{editorBean.message}" />
<br/>
Value = <h:outputText value="#{editorBean.value}" />
我的托管 bean 中有两个 String
属性以及相应的 getter 和 setter。
@ManagedBean
@SessionScoped
public class EditorBean implements Serializable {
private String value="hello how are you";
private String message="hello how are you";
public EditorBean() {
value="hello how are you guys?";
message="dd";
}
// ...
}
我想在不同的行中呈现两个字符串。
<h:outputText value="#{editorBean.message}" />
<h:outputText value="#{editorBean.value}" />
但它们显示在一行中。
ddhello how are you guys?
这是怎么引起的,我该如何解决?
你的程序没有问题我测试了你的程序,我得到了这样的结果:
所以它向您展示了这一点,因为您已经更改了构造函数中的值:
public EditorBean() {
value="hello how are you guys?";
message="dd";
}
所以你应该 ddhello how are you guys?
----------------------^--------^
所以如果你想展示:
private String value="hello how are you";
private String message="hello how are you";
你不应该在你的构造函数中再次初始化它们。
备注
试试看到底发生了什么:
Message = <h:outputText value="#{editorBean.message}" />
<br/>
Value = <h:outputText value="#{editorBean.value}" />