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

类型Servlet商品管理系统.docx

  • 文档编号:23445722
  • 上传时间:2023-05-17
  • 格式:DOCX
  • 页数:23
  • 大小:63.80KB

 

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

2)代码:

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

 

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

3)代码:

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

 

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

4)代码:

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

 

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

5)代码:

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

 

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

6)代码:

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

<%

intcurrentPage=1;

intfirstCount=1;

intendCount=1;

Listlist=null;

list=(ArrayList)("list");

inteveryPage=2;

inttotalCount=();

inttotalPage=totalCount/everyPage+1;

+totalPage);

+totalCount);

StringpageNum=("pageNum");

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

currentPage=1;

}else{

currentPage=(pageNum);

if(currentPage<=0){

currentPage=1;

}elseif(currentPage>totalPage){

currentPage=totalPage;

}

}

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

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

}

+currentPage);

+firstCount);

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

endCount=firstCount+everyPage;

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

endCount=firstCount+totalCount%everyPage;

}

+endCount);

%>

id

商品名称

商品数量

<%

for(inti=firstCount;i

%>

<%=((i-1)).getId()%>

<%=((i-1)).getName()%>

<%=((i-1)).getNum()%>

<%

}

%>

?

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

?

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

/">gobacktomainpage

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

2、Servlet源代码

1)AddServlet代码:

(仅列出关键部分)

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

orward(request,response);

}

catch(SQLExceptione)

{

}

}

publicvoidShowAll(HttpServletRequestrequest,HttpServletResponseresponse)throwsIOException,ServletException

{

ArrayListl=newArrayList();

try

{

}

catch(Exceptione)

{

}

try

{

stmt=();

Stringsql=newString("select*fromshangpin");

rs=(sql);

l=(ArrayList)MakeList(rs);

HttpSessions=();

("list",l);

("/").forward(request,response);

}

catch(SQLExceptione)

{

}

}

publicListMakeList(ResultSetrs)throwsSQLException

{

Listl=newArrayList();

while())

{

Productp=newProduct

(1),

(2),(3));

(p);

}

returnl;

}

publicvoidinit()throwsServletException{

}

}

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

2)QueryServlet代码:

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

publicvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)

throwsServletException,IOException{

id=("id");

name=("name");

a=("num");

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

{

num=0;

}

elsenum=(a);

if(id!

=null&&!

(""))

{

QueryById(request,response,id);

}

elseif(name!

=null&&!

(""))

{

QueryByName(request,response,name);

}

elseif(num!

=0)

{

QueryByNum(request,response,num);

}

else

ShowAll(request,response);

}

publicvoidQueryById(HttpServletRequestrequest,HttpServletResponseresponse,Stringid)

{

ArrayListl=newArrayList();

try

{

conn=

}

catch(Exceptione)

{

"Openconn:

"+());

}

try

{

stmt=();

Stringsql=newString("select*fromshangpinwhereid="+"'"+id+"'");

rs=(sql);

l=(ArrayList)MakeList(rs);

Http

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

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

特殊限制:

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

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

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

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

收起
展开