为什么啊,明明是数值,就是到联接位置运算不成呢,请教请教,求助!!
<%@ page contentType= "text/html; charset=gb2312 " language= "java " import= "java.sql.* " import= "java.lang.String " errorPage= " " %>
<%
request.setCharacterEncoding( "gb2312 ");
%>
<%@ include file= "conn.jsp "%>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<title> 无标题文档 </title>
<link href= "css/Style.css " type= "text/css " rel= "stylesheet " />
</head>
<body>
<table width= "700 " border= "0 " align= "center " cellpadding= "0 " cellspacing= "0 " bordercolor= "#D4D0C8 ">
<tr>
<td> <div align= "center "> 人员管理 </div> </td>
</tr>
<tr>
<td> <form id= "form1 " name= "form1 " method= "post " action= " ">
<table width= "400 " border= "1 " align= "center " cellpadding= "0 " cellspacing= "0 " bordercolor= "#D4D0C8 ">
<tr>
<td colspan= "2 "> </td>
</tr>
<tr>
<td> 姓名 </td>
<td> <label>
<input type= "text " name= "textfield " />
</label> </td>
</tr>
<tr>
<td> 性别 </td>
<td> <label>
<select name= "select ">
<option> 请选择 </option>
<option value= "1 "> 男 </option>
<option value= "0 "> 女 </option>
</select>
</label> </td>
</tr>
<tr>
<td> 年龄 </td>
<td> <label>
<select name= "select2 ">
<option> 请选择 </option>
<option value= "1 "> 20-30 </option>
<option value= "2 "> 30-40 </option>
<option value= "3 "> 40-50 </option>
</select>
</label> </td>
</tr>
<tr>
<td> 职务 </td>
<td> <label>
<select name= "select3 ">
<option> 请选择 </option>
</select>
</label> </td>
</tr>
<tr>
<td> 工资 </td>
<td> <label>
<select name= "select4 ">
<option> 请选择 </option>
<option value= "1 "> 1000-2000 </option>
<option value= "2 "> 2000-3000 </option>
</select>
</label> </td>
</tr>
<tr>
<td> 部门 </td>
<td> <label>
<select name= "select5 ">
<option> 请选择 </option>
</select>
</label> </td>
</tr>
<tr>
<td> 工作地区 </td>
<td> <label>
<select name= "select6 ">
<option> 请选择 </option>
</select>
</label> </td>
</tr>
<tr>
<td colspan= "2 "> <label>
<div align= "center ">
<input type= "submit " name= "Submit " value= "模糊查询 " />
<input type= "submit " name= "Submit2 " value= "查看全部 " />
</div>
</label> </td>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td> <table width= "100% " border= "1 " cellspacing= "0 " cellpadding= "0 ">
<tr>
<td width= "60 "> <p> 帐号 </p> </td>
<td width= "81 "> 姓名 </td>
<td width= "31 "> 性别 </td>
<td width= "29 "> 年龄 </td>
<td width= "102 "> <p> 联系电话 </p> </td>
<td width= "38 "> 职务 </td>
<td width= "68 "> 工资 </td>
<td width= "74 "> 工作时间 </td>
<td width= "31 "> 部门 </td>
<td width= "56 "> 工作地区 </td>
<td width= "32 "> 备注 </td>
<td width= "33 "> 修改 </td>
<td width= "37 "> 删除 </td>
</tr>
<%
try {
//Class.forName( "net.sourceforge.jtds.jdbc.Driver ");
//Connection con=DriverManager.getConnection( "jdbc:jtds:sqlserver://192.168.0.100:1433/aa;tds=8.0;lastupdatecount=true ", "sa ", " ");
Statement stmt=con.createStatement();
ResultSet rs1=stmt.executeQuery( "select count(*) from gsryb ");
rs1.next();
int flag=rs1.getInt(1);
%>
<jsp:useBean id= "bib " scope= "request " class= "bean.CustomerPage " type= "bean.CustomerPage ">
</jsp:useBean>
<%
int page1=10; //每页条数
int pages; //当前页
if (request.getParameter( "pages ")==null) {
pages=1;
} else {
pages = new Integer(request.getParameter( "pages ")).intValue();
}
int sa=pages;
String flag1=bib.Page(pages,flag,page1);
ResultSet rs=stmt.executeQuery(flag1);
while(rs.next())
{
//ryid,pass,ryname,sex,age,phone,job,sal,hirdate,bmid,areaat,memo
%>
<tr>
<td> <%=rs.getString( "ryid ")%> </td>
<td> <%=rs.getString( "ryname ")%> </td>
<td> <%=rs.getString( "sex ")%> </td>
<td> <%=rs.getString( "age ")%> </td>
<td> <%=rs.getString( "phone ")%> </td>
<td> <%=rs.getString( "job ")%> </td>
<td> <%=rs.getString( "sal ")%> </td>
<td> <%=rs.getString( "hirdate ")%> </td>
<td> <%=rs.getString( "bmid ")%> </td>
<td> <%=rs.getString( "areaat ")%> </td>
<td> <%=rs.getString( "memo ")%> </td>
<td> <a href= "ryup.jsp " target= "mainFrame "> 修改 </a> </td>
<td> <a href= "rydel.jsp " target= "mainFrame "> 删除 </a> </td>
</tr>
<%
}
con.close();
}
catch (Exception ex) {
ex.printStackTrace();
}
%>
<tr>
<td colspan= "13 "> <a href= "1 "> 上一页 </a> <a href= "ry1.jsp?pages= <%=sa+1%> "> 下一页 </a> </td>
</tr>
</table> </td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</body>
</html>
问题,就在这
<a href= "ry1.jsp?pages= <%=sa+1%> "> 下一页 </a>
就是不好使,
提示错误是:
C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\xm\org\apache\jsp\ry1_jsp.java:140: cannot resolve symbol
symbol : variable sa
location: class org.apache.jsp.ry1_jsp
out.print(sa+1);
^
1 error
[解决办法]
把sa声明放到try语句之前
try前加上int sa=0;
int sa=pages;换为sa=pages;