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>