開始!彼らは悪い習慣であり、ビジネスロジックがビューレイヤーに漏れてしまいます。
JSTLを使用してタグファイルを作成できます。それはかなりシンプルです。 Thisは良いスタート地点です。
例:
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>
タグが/WEB-INF/tags
であると仮定すると、あなたは、このようにそれを使用することができます:
<%@ taglib prefix="mystuff" tagdir="/WEB-INF/tags" %>
<mystuff:mytable cell1="hello" cell2="world" />
を私のシナリオでI私のjstlの断片を再利用したい – van