<#list pageView.list as msg>
<form name="msgForm" id="msgForm" action="findMsgById.do" method="post">
<tr class="tr3" onMouseOver="this.style.backgroundColor='whitesmoke'"
onMouseOut="this.style.backgroundColor='white'">
<td align="center">
<span class="style_blue_tableline">${msg_index+1}
</span>
</td>
<td align="center">
<span class="style_blue_tableline">
<a id="editmsg" name="editmsg"
style="cursor:pointer;color:blue;text-decoration: underline">
修改
</a>
</span>
<span class="style_blue_tableline">
<a href="logicDelMsg.do?messageId=${msg.messageId}" >删除
</a>
</span>
</td>
<input type="hidden" id="messageId" name="messageId" value="${msg.messageId}" />
<td align="center">
<span class="style_blue_tableline">${msg.title}nbsp;
</span>
</td>
<td align="center">
<span class="style_blue_tableline">${msg.messageContent}
</span>
</td>
<td align="center">
<span class="style_blue_tableline">${msg.sendTime?string("yyyy-MM-dd HH:mm:ss")}
</span>
</td>
<td align="center">
<span class="style_blue_tableline">${msg.sender}
</span>
</td>
</tr>
</form>
</#list>
如以上所示,如果EL表达式中的值为空,则会报如下异常:
the expression msg.title is undefine ....
原因是:freemarker不像jsp那样,可以在页面上自动处理空值。
这时,应该将每个EL表达式改成如下:
${(msg.title)?default("")}
表示:如果这个值为空,则给一个默认值。
默认值可任意指定。