书签 分享 收藏 举报 版权申诉 / 25

类型Servlet商品管理系统.docx

  • 文档编号:9401920
  • 上传时间:2023-02-04
  • 格式:DOCX
  • 页数:25
  • 大小:64.52KB

 

...................................................

2)Query.jsp代码:

...................................................

 

..................................................

3)Add.jsp代码:

..................................................

 

..................................................

4)Update.jsp代码:

..................................................

 

..................................................

5)Delete.jsp代码:

..................................................

 

..................................................

6)Result.jsp代码:

..................................................

<%

intcurrentPage=1;

intfirstCount=1;

intendCount=1;

Listlist=null;

list=(ArrayList)session.getAttribute("list");

inteveryPage=2;

inttotalCount=list.size();

inttotalPage=totalCount/everyPage+1;

StringpageNum=request.getParameter("pageNum");

if(pageNum==null||pageNum.equals("")){

currentPage=1;

}else{

currentPage=Integer.parseInt(pageNum);

if(currentPage<=0){

currentPage=1;

}elseif(currentPage>totalPage){

currentPage=totalPage;

}

}

if(currentPage>0&¤tPage<=totalPage){

firstCount=(currentPage-1)*everyPage+1;

}

if(currentPage>0&¤tPage<=(totalPage-1)){

endCount=firstCount+everyPage;

}elseif((currentPage)>0&&(currentPage==totalPage)){

endCount=firstCount+totalCount%everyPage;

}

%>

id

商品名称

商品数量

<%

for(inti=firstCount;i

%>

<%=((MyPackage.Product)list.get(i-1)).getId()%>

<%=((MyPackage.Product)list.get(i-1)).getName()%>

<%=((MyPackage.Product)list.get(i-1)).getNum()%>

<%

}

%>

Result.jsp?

pageNum=<%=currentPage-1%>">上一页

Result.jsp?

pageNum=<%=currentPage+1%>">下一页

/Main.jsp">gobacktomainpage

..................................................

2、Servlet源代码

1)AddServlet代码:

(仅列出关键部分)

..................................................

//关键变量:

Stringid=newString();

Stringname=newString();

intnum;

Stringa=newString();

Stringsql1=newString();

Stringsql2=newString();

Connectionconn=null;

Statementstmt=null;

ResultSetrs=null;

PreparedStatementps=null;

//关键函数

publicvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)

throwsServletException,IOException

{

id=request.getParameter("id");

name=request.getParameter("name");

a=request.getParameter("num");

if(a==null||a.equals(""))

{

num=0;

}

elsenum=Integer.parseInt(a);

if(id!

=null&&!

id.equals(""))

{

Add(request,response,id,name,num);

}

else

ShowAll(request,res

举报
举报
版权申诉
版权申诉
word格式文档无特别注明外均可编辑修改;预览文档经过压缩,下载后原文更清晰! 立即下载
配套讲稿:

如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。

特殊限制:

部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。

关 键  词:
Servlet 商品 管理 系统
提示  冰豆网所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。
关于本文
本文标题:Servlet商品管理系统.docx
链接地址:https://www.bdocx.com/doc/9401920.html
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2008-2022 冰点文档网站版权所有

经营许可证编号:鄂ICP备2022015515号-1

收起
展开