jsp页面中有个pageNow变量
我想用<s:if>来做一些判断,该怎么写呢? 我是这么写的,不过一直不对,求解<s:set name="pageNow" value="pageNow"/>
<s:if test="#pageNow!=1">
<a href="queryall.action?pageNow=<%=pageNow-1 %>">上一页</a>
</s:if>
我想用<s:if>来做一些判断,该怎么写呢? 我是这么写的,不过一直不对,求解<s:set name="pageNow" value="pageNow"/>
<s:if test="#pageNow!=1">
<a href="queryall.action?pageNow=<%=pageNow-1 %>">上一页</a>
</s:if>
<s:if test="#request.pageNow!=1">
<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%@ taglib prefix = "s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
List list = (List)request.getAttribute("list");
String spageCount = request.getAttribute("count").toString();
int pageCount = Integer.parseInt(spageCount);
String spageNow = request.getAttribute("pageNow").toString();
int pageNow = Integer.parseInt(spageNow);
String sdataCount = request.getAttribute("dataCount").toString();
int dataCount = Integer.parseInt(sdataCount);
String spageSize = request.getAttribute("pageSize").toString();
int pageSize = Integer.parseInt(spageSize);
System.out.println("list为空吗:"+list.isEmpty());
System.out.println("共有"+list.size()+"条记录");
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title></title>
<script type="text/javascript">
<!--
function checkSubmit()
{
var temp = document.getElementsByName("condition");
var a;
f=document.form1.conditiontext.value;
var reg= /^\d{1,20}$/;
if(f == ''){
alert("筛选条件不能为空!");
return false;
}
for(var i=0;i<temp.length;i++)
{
if(temp[i].checked)
a = temp[i].value;
}
if(a == "cid")
{
if(f.match(reg)){
return true;
}
else
{
alert("请输入正确的数值!");
return false;
}
}
}
-->
</script>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
</head>
<body>
<table width="100%" border="0" align="center">
<tr>
<td bgcolor="#E1DFDC" height="400" vAlign="top"><br/>
<div align="center">
<form action="/TuShu/query-id.action" method="post" name="form1" onSubmit="return checkSubmit()">
<input type="text" name="conditiontext">
<input type="submit" value="查找">
<input type="radio" value="cid" name="condition" checked>按编号
<input type="radio" value="cname" name="condition">按书名
<input type="radio" value="cpublish" name="condition">按出版社
<input type="radio" value="category" name="condition">按类别
</form>
</div>
<hr>
<div align="center">
</div><table width="100%" border="1" align="center">
<tr>
<th align="center"><strong>书籍编号</strong></th>
<th align="center"><strong>书籍名称</strong></th>
<th align="center"><strong>书籍作者</strong></th>
<th align="center"><strong>出版社</strong></td>
<th align="center"><strong>ISBN</strong></th>
<th align="center"><strong>书籍价格</strong></th>
<th align="center"><strong>书籍类别</strong></th>
<th align="center"><strong>租借状态</strong></th>
<th align="center"><strong></strong></th>
<th align="center"><strong></strong></th>
</tr>
<s:iterator value="#request.list">
<tr>
<td align="center"><s:property value="id"/></td>
<td align="center"><s:property value="bookname"/></td>
<td align="center"><s:property value="writer"/></td>
<td align="center"><s:property value="publish"/></td>
<td align="center"><s:property value="isbn"/></td>
<td align="center"><s:property value="price"/></td>
<td align="center"><s:property value="category"/></td>
<td align="center"><s:property value="isborrowed"/></td>
<td align="center"><a href="/TuShu/modifyquery.action?id=<s:property value="id"/>">修改</a></td>
<td align="center"><a href="/TuShu/deletedetail.action?id=<s:property value="id"/>">删除</a></td>
</tr>
</s:iterator>
</table>
<%if(list.isEmpty() == true ){ %><div align="center"><font color="#ff0000"><strong>未找到任何相关记录</strong> <%} %>
<% if(list.isEmpty() == false && dataCount>pageSize){%>
<br> <a href="queryall.action?pageNow=1">首页</a>
<s:set name="pageNow" value="pageNow"/>
<s:if test="pageNow!=1">
<a href="queryall.action?pageNow=<%=pageNow-1 %>">上一页</a>
</s:if>
<%for(int i=pageNow;i<=pageCount;i++){%>
<a href="queryall.action?pageNow=<%=i %>"><%=i %></a> <% }%>
<%if(pageNow!=pageCount){%>
<a href="queryall.action?pageNow=<%=pageNow+1 %>">下一页</a>
<%} %>
<a href="queryall.action?pageNow=<%=pageCount %>">尾页</a>
共有<%=dataCount %>条记录,当前第<%=pageNow %>页,共<%=pageCount %>页<%} %>
</td>
</tr>
</table>
</body>
</html>
<s:if test="%{#pageNow!=\"1\"}">
<s:set name="pageNow" value="pageNow"/>name="pageNow":pageNow是属性名。
value="pageNow":pageNow是属性值。判断属性pageNow不等于1,而pageNow = "pageNow",所以显示上一页。