struts2 タグ ライブラリを使用して以下のコードを記述する方法。struts2にはイテレータやifなどのタグがたくさんあるので、それを使って以下のコードをどのように実現できますか?
struts2 タグで変数を初期化する方法と、その後、以下に示すコードのようにインクリメントまたはデクリメント操作を適用する方法を教えてください。
int j=-1;
for(int i=0;i<4;i++)
{
j++;
if(j==0)
{
}
if(j==1)
{
}
if(j==2)
{
j=-1;
}
}
これは、scriplet タグ内で Java コードを使用した私の JSP ページです。
<h3>Our Latest Projects</h3>
<%! int j = -1; %>
<%
for (int i = 0; i < 4; i++) {
j++;
%>
<% if (j == 0) { %>
<div class="wrapper">
<article class="grid_4 alpha">
<h4 class="p2">Project 1</h4>
<figure><a href="#"><img class="img-border" src="images/page4-img1.jpg" alt=""/></a></figure>
<div class="box" style="height: 20px; width: 257px;">
<div class="padding">
<a href="#">View Details</a>
</div>
</div>
</article>
<% } %>
<% if (j == 1) { %>
<article class="grid_4">
<div class="indent-left4">
<h4 class="p2">Project 2</h4>
<figure><a href="#"><img class="img-border" src="images/page4-img2.jpg" alt=""/></a></figure>
<div class="box" style="height: 20px; width: 257px;">
<div class="padding">
<a href="#">View Details</a>
</div>
</div>
</div>
</article>
<% } %>
<% if (j == 2) { %>
<article class="grid_4 omega">
<div class="indent-left3">
<h4 class="p2">Project 3</h4>
<figure><a href="#"><img class="img-border" src="images/page4-img3.jpg" alt=""/></a></figure>
<div class="box" style="height: 20px; width: 257px;">
<div class="padding">
<a href="#">View Details</a>
</div>
</div>
</div>
</article>
</div>
<br><br>
<% j = -1; %>
<% } %>
<% } %>