更新时间:2023-12-04 17:13:53
True, JSP has some templating capabilities, but the biggest disadvantage of using JSP in JSF is that JSP writes to the response as soon as it encounters template text content, while JSF would like to do some pre/post processing with it. In JSF 1.0/1.1 the following JSF code
<h:outputText value="first"> second <h:outputText value="third"> fourth
会产生
第二个第四个第三个
second fourth first third
This was during the JSF 1.0/1.1 ages a headache. Developers would need to wrap template text like second
and fourth
in the above example in <f:verbatim>
tags over all place. JSF 1.2 has solved it with an improved view handler which parses the JSP instead of executing it, but it was under the hoods still very clumsy as JSP syntax isn't "well-formed" like XML. A XML based view technology was strongly desired, so that an efficient SAX based parser could be used. And Facelets was born (among Ken Paulsen's "JSFTemplating").
此外,统一的EL #{}
不能在JSP模板文本中使用,从而导致丑陋的表情-对于初学者来说视图建立时间标签.此外,带有<% %>
事物的JSP语法已经过时了,将原始Java代码嵌入JSP的可能性被认为是 MVC意识形态.
Also, unified EL #{}
couldn't be used in JSP template text, resulting in ugly —and for starters unintuitive— mixing of ${}
and #{}
. Also, JSTL could in JSF 1.x on JSP not be used as view build time tags. Also, JSP syntax with <% %>
things is old school and the possibility of embedding raw Java code in JSP is considered a very poor practice which breaks MVC ideology.
总而言之,从JSF/MVC的角度来看,JSP只是丑陋而可怕,而Facelets却干净整洁.
All with all, in JSF/MVC perspective, JSP is simply ugly and terrible and Facelets is simply clean and awesome.