JSF输出是HTML/XML,并且ResponseWriter
可以更容易地正确生成它.假设您想要在标记中呈现一些文本.
My random text
代码看起来像:
ResponseWriter writer=context.getResponseWriter(); writer.startElement("span", component); writer.writeText(text, null); writer.endElement("span");
writerAttribute
当您需要向标记添加ID或类属性时,会出现这种情况.
ResponseWriter writer=context.getResponseWriter(); writer.startElement("span", component); writer.writeAttribute("id", id, null); writer.writeText(text, null); writer.endElement("span");
这将呈现:
My text
注意:writeAttribute
紧接着startElement
.一旦你启动另一个元素或写一些文字,你就无法打电话writeAttribute
.
JSF输出是HTML/XML,并且ResponseWriter
可以更容易地正确生成它.假设您想要在标记中呈现一些文本.
My random text
代码看起来像:
ResponseWriter writer=context.getResponseWriter(); writer.startElement("span", component); writer.writeText(text, null); writer.endElement("span");
writerAttribute
当您需要向标记添加ID或类属性时,会出现这种情况.
ResponseWriter writer=context.getResponseWriter(); writer.startElement("span", component); writer.writeAttribute("id", id, null); writer.writeText(text, null); writer.endElement("span");
这将呈现:
My text
注意:writeAttribute
紧接着startElement
.一旦你启动另一个元素或写一些文字,你就无法打电话writeAttribute
.