资源简介
个人项目,没用三大框架,用了servlet、javabean、jsp、oracle历时一个月完成,
代码片段和文件信息
package action;
import java.io.UnsupportedEncodingException;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.http.HttpServletRequest;
import dao.Conn;
public class Before {
public ResultSet searchData(HttpServletRequest request) throws SQLException
{
try {
request.setCharacterEncoding(“utf-8“);
} catch (UnsupportedEncodingException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
int realpage = 0;
int pagesize = 3;
ResultSet rs1=null;
String curpage=request.getParameter(“curpage“);
String rowCount1=“select count(*) from t_product_140 where 1=1“;
ResultSet rs=null;
String sqlwhere=“ “;
String sql=“select * from “ ;
String sqlfrom=“(select t.* rownum as row_number from t_product_140 t where 1=1“;
String tid=request.getParameter(“tid“);
String tname=request.getParameter(“tname“);
request.setAttribute(“tid“tid);
request.setAttribute(“tname“tname);
if(tid!=null&&!tid.equals(““))
{
sqlwhere= “and T_PRODUCTID= ‘“ +tid + “‘“;
}
if(tname!=null&&!tname.equals(““))
{
sqlwhere = sqlwhere + “and T_PRODUCTNAME= ‘“ +tname + “‘“;
}
sql=sql+sqlfrom+sqlwhere+“order by t_productid) where row_number between “;
rowCount1=rowCount1+sqlwhere;
//查询页码,起始和结束行号
try {
PreparedStatement psmt1 = Conn.conn.prepareStatement(rowCount1);
rs1 = psmt1.executeQuery();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
String rowCount=““;
while (rs1.next()) {
rowCount=rs1.getString(1);
}
int rowbegin = (Integer.parseInt(curpage)-2)*pagesize + 1;
int endrow=(Integer.parseInt(curpage)-1)*pagesize;
int xx = Integer.parseInt(rowCount) % pagesize;
if (xx == 0) {
realpage = (Integer.parseInt(rowCount)/ pagesize);
} else {
realpage = (Integer.parseInt(rowCount)/ pagesize) + 1;
}
request.setAttribute(“realpage“ String.valueOf(realpage));
//商品查询
if(Integer.parseInt(curpage)>1){
sql=sql
+ String.valueOf(rowbegin)
+ “ and “
+ String.valueOf(endrow);
try {
PreparedStatement psmt = Conn.conn.prepareStatement(sql);
rs = psmt.executeQuery();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else{
rowbegin = 1;
endrow=pagesize;
sql=sql
+ String.valueOf(rowbegin)
+ “ and “
+ String.valueOf(endrow);
try {
PreparedStatement psmt = Conn.conn.prepareStatement(sql);
rs = psmt.executeQuery();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return rs;
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 435 2012-06-04 15:39 Shop\.classpath
文件 285 2012-07-06 16:49 Shop\.myme
文件 1222 2012-06-04 11:37 Shop\.project
文件 2804 2012-06-25 14:18 Shop\src\action\Before.java
文件 2890 2012-06-25 09:33 Shop\src\action\buy.java
文件 4527 2012-06-29 11:00 Shop\src\action\buycar.java
文件 4209 2012-06-29 10:58 Shop\src\action\buyed.java
文件 2536 2012-06-25 13:46 Shop\src\action\buying.java
文件 750 2012-06-06 14:50 Shop\src\action\DeleteShop.java
文件 1127 2012-06-29 11:25 Shop\src\action\Login.java
文件 3183 2012-06-25 16:14 Shop\src\action\Next.java
文件 3356 2012-06-21 16:00 Shop\src\action\reg.java
文件 4220 2012-06-29 11:01 Shop\src\action\selled.java
文件 1706 2012-06-29 11:08 Shop\src\action\shangpin.java
文件 2527 2012-06-25 14:12 Shop\src\action\ShopSearch.java
文件 6995 2012-06-08 13:24 Shop\src\action\ShopSearch_jsp.class
文件 1621 2012-06-08 10:37 Shop\src\common\fenye1.java
文件 578 2012-06-04 15:28 Shop\src\dao\Conn.java
文件 87562 2012-06-20 10:45 Shop\WebRoot\7755736_155203443113_2.jpg
文件 17663 2012-06-06 15:17 Shop\WebRoot\bgpic.JPG
文件 2267 2012-06-21 16:38 Shop\WebRoot\buy.jsp
文件 2957 2012-06-29 10:38 Shop\WebRoot\buycar.jsp
文件 2576 2012-06-29 10:35 Shop\WebRoot\buyed.jsp
文件 61 2012-06-04 16:32 Shop\WebRoot\C4.jsp
文件 710 2012-06-20 16:47 Shop\WebRoot\Copy of index.jsp
文件 433 2012-06-29 11:15 Shop\WebRoot\head.jsp
文件 433 2012-06-29 11:15 Shop\WebRoot\head1.jsp
文件 710 2012-06-20 16:47 Shop\WebRoot\index.jsp
文件 1518 2012-06-29 11:08 Shop\WebRoot\left.jsp
文件 1355 2012-06-29 11:14 Shop\WebRoot\left1.jsp
............此处省略49个文件信息
评论
共有 条评论