Viv*_*ath 30
不要使用scriptlet!它们是一种不好的做法,它们让业务逻辑泄漏到您的视图层.
您可以使用JSTL创建标记文件; 这很简单.这是一个很好的起点.
一个例子:
mytable.tag:
<%@ attribute name="cell1" required="true" type="java.lang.String" description="Text to use in the first cell." %>
<%@ attribute name="cell2" required="false" type="java.lang.String" description="Text to use in the second cell." %>
<table>
<tr>
<td id = "cell1">${cell1}</td>
<td id = "cell2">${cell2}</td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
假设你的标签在/WEB-INF/tags,你可以像这样使用它:
<%@ taglib prefix="mystuff" tagdir="/WEB-INF/tags" %>
<mystuff:mytable cell1="hello" cell2="world" />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10782 次 |
| 最近记录: |