急求高人:JSP自定义的分页标签问题?

来源:百度知道 编辑:UC知道 时间:2024/09/24 00:37:04
写了一个自定义的分页标签,这个标签体的字符有部分的[{xx}]内容,xx如果写上数据库的列名,在标签体里用正则表达式匹配出[{xx}]中的xx部分,用String的replace方法,转换成rs.getString("xx");用out.println();输出到页面上显示分页,分页可以显示,但是显示出来的数据一般需要判断,假设标签体有[{sex}]字符串,则标签转换为out.println(rs.getString("sex"));转换一下,输出,如果数据库中存储的为 b或g,显示的时候就需要判断一下,如果为b就显示男,为g就显示女,问题就在这里,如何判断呢?标签体内容如下:
<my:page sql="select * from pubs..jobs" >
<tr>
<td>[{job_id}]</td>
<td>[{job_desc}]</td>
<td>[{max_lvl}]</td>
<td>[{min_lvl}]</td>
<td><a href="?id=[{job_id}]">删除</a></td>
tr>
</my:page>

用jstl标签 :
<c:choose>

<c:when test="${condition1}">

condition1为true

</c:when>

<c:when test="${ condition2}">

condition2为true

</c:when>

<c:otherwise>

condition1和condition2都为false

</c:otherwise>

</c:choose>

范例说明:当condition1为true时,会显示“condition1为true”;当condition1为false且condition2为true时,会显示“condition2为true”,如果两者都为false,则会显示“condition1和condition2都为false”。

或者用 struts 标签:
<logic:equel name="b">
out.print("男");
</logic:equel>
<logic:equel name="g">
out.print("女");
</logic:equel>
<logic:equel name="">
 
</logic:equel>