EL 改善了代碼的可都性,在上面的例子中WW 調用Action的getGuessBean() 然后調用bean的 getNumGuesses() 。現在來比較這些精簡的符號與第二個JSP列表. WW方式是更精簡,易于閱讀,表達得更清楚,我們不用擔心范圍、類、方法等,頁面設計者不應該厭煩這些信息。 條件判定范例: ? WW方式 ? <webwork:if test="guessBean/sUCcess==true"/> ? Congratulations! You got it. ? And after just <webwork:property value="guessBean/numGuesses"/> tires.<p> ? Not sure what to do here? ? Care to <a href="<webwork:url page="numguess.action?begin=true"/>">try again</a>? ? </webwork:if>
? 普通JSP 方式 ? <% if (numguess.getSuccess()) { %> ? Congratulations! You got it. ? And after just <%= numguess.getNumGuesses() %> tries. <p> ? <% numguess.reset(); %> ? Not sure what to do here? ? Care to <a href="<%=response.encodeURL(numguess.jsp)%>"/>">try again</a>? ? <% } %>
? 可以計算兩個操作數的條件表達式You can evaluate conditionally with two Operands. 例子中,假如if條件為true,就執if的主體。 ? <webwork:if test="′hello′ == ′hello′"> ? <b>Success</b> ? </webwork:if>
? You can set precedence when evaluating conditional expressions with (). In this example, we group conditional expressions together. Note that the operands are themselves value expressions. ? <webwork:if test="bool(′true′) == true && (bool(′false′) == true settings[′foo′] == ′bar′)"> ? <b>Success</b> ? </webwork:if>