开发者

Performance of using jsf outputText to render html

A quick question, which is better performance and memory wise:

<t:outputText escape="false" value='<tr><td>'/>

or just a straight

开发者_开发技巧<tr><td>

I ask because I haven't found any documentation regarding which is best performance wise and for general maintainability of the JSFs. I believe the latter results in more maintainable code (you can identify mismatched tags easier), but I'm unaware if there are reasons someone would want to explicitly output html elements using outputText.


Just put HTML straight in the view. Not only have the components indeed an extra memory/resource overhead which you'd like to minimize, but it's also much better readable.

The example as you posted will by the way also not parse when you're using Facelets instead of JSP as view technology.


I am afraid the first example won't work at all:

  1. outputText is usually generated as <span> tag with the text inside so it will not do what you want EDIT: See comments
  2. It is possible that it will escape the < and > characters so it will not create html tags tr and td at all, just the text: &lt;tr&gt;&lt;td&gt; (see escape attribute)

The second is generally not a good idea since the tag is intended to output text to the page and not html tags.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜