Servlet 商品管理系统文档格式.docx

上传人:b****6 文档编号:17473710 上传时间:2022-12-01 格式:DOCX 页数:18 大小:20.42KB
下载 相关 举报
Servlet 商品管理系统文档格式.docx_第1页
第1页 / 共18页
Servlet 商品管理系统文档格式.docx_第2页
第2页 / 共18页
Servlet 商品管理系统文档格式.docx_第3页
第3页 / 共18页
Servlet 商品管理系统文档格式.docx_第4页
第4页 / 共18页
Servlet 商品管理系统文档格式.docx_第5页
第5页 / 共18页
点击查看更多>>
下载资源
资源描述

Servlet 商品管理系统文档格式.docx

《Servlet 商品管理系统文档格式.docx》由会员分享,可在线阅读,更多相关《Servlet 商品管理系统文档格式.docx(18页珍藏版)》请在冰豆网上搜索。

Servlet 商品管理系统文档格式.docx

3、修改模块设计

修改模块功能分为两种情况首先,若填入ID不为空,则按照填入消息对SQL语句进行传递,修改后再次查询所有表项,显示出来后证明确实将所需修改的表项进行了修改;

若ID为空,为默认情况,调用ShowAll()函数,全部显示。

4、删除模块设计

删除功能分为四种情况,首先,若填入ID不为空,则按照ID删除,调用DeleteById()函数;

若ID为空,判断name是否为空,若不为空,则按照name删除,调用DeleteByName()函数;

若name为空,判断num是否为空,若不为空,则按照num删除,调用DeleteByNum()函数;

大致框架如下:

5、Product类设计

该类的主要功能是将表项封装到一个实例中去,而后将实例一次放入一个list中,而后可以通过检索list来一次输出,因此,Product类中主要有与数据库表项相匹配的变量和相应变量的get、set方法。

六、JSP设计

上述四个JSP子页面的主要功能是为了给用户提供输入框,根据条件获取相应数据库表项,因此JSP大致需一下几个部分:

首先是为了和Servlet相关联的form:

<

formname="

query"

method=postaction="

servlet/QueryServlet"

>

<

/form>

在form中添加入文字和文本域供用户使用,例如:

inputtype="

text"

name="

id"

size=30>

还有提交按钮,触发Servlet行为,例如:

submit"

value="

Query"

7、UI界面美化

为了使用户使用时更加美观、方便,这里使用可视化的Dreamweaver软件进行界面设计、图片插入,而后将JSP代码填入具体JSP进行路径、链接配置。

8、环境配置

1、Java运行环境:

MyEclipse,Javawebproject;

2、数据库平台:

MySql;

3、服务器平台:

TomCat6;

关键程序源代码

1、JSP源代码

1)代码:

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

body>

divalign="

center"

/div>

tablewidth="

606"

height="

435"

border="

0"

tr>

tdheight="

334"

colspan="

4"

imgsrc="

images/"

width="

627"

333"

/>

/td>

/tr>

tdwidth="

155"

95"

ahref="

"

150"

85"

/a>

146"

134"

153"

/table>

pclass="

STYLE1"

&

nbsp;

/p>

/body>

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

2)代码:

add"

method="

Post"

action="

671"

342"

2"

164"

160"

80"

459"

>

77"

td>

name"

73"

num"

82"

查询"

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

3)代码:

4)代码:

servlet/UpdateServlet"

添加"

5)代码:

delete"

servlet/DeleteServlet"

删除"

6)代码:

%

intcurrentPage=1;

intfirstCount=1;

intendCount=1;

Listlist=null;

list=(ArrayList)("

list"

);

inteveryPage=2;

inttotalCount=();

inttotalPage=totalCount/everyPage+1;

StringpageNum=("

pageNum"

if(pageNum==null||("

)){

currentPage=1;

}else{

currentPage=(pageNum);

if(currentPage<

=0){

currentPage=1;

}elseif(currentPage>

totalPage){

currentPage=totalPage;

}

}

if(currentPage>

0&

currentPage<

=totalPage){

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

=(totalPage-1)){

endCount=firstCount+everyPage;

}elseif((currentPage)>

(currentPage==totalPage)){

endCount=firstCount+totalCount%everyPage;

%>

<

485"

1"

align="

<

<

tdalign="

id

商品名称

商品数量

for(inti=firstCount;

i<

endCount;

i++){

%>

<

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

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

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

}

%>

%=basePath%>

pageNum=<

%=currentPage-1%>

上一页<

%=currentPage+1%>

下一页<

/"

gobacktomainpage<

2、Servlet源代码

1)AddServlet代码:

(仅列出关键部分)

orward(request,response);

}

catch(SQLExceptione)

{

}

publicvoidShowAll(HttpServletRequestrequest,HttpServletResponseresponse)throwsIOException,ServletException

{

ArrayListl=newArrayList();

try

catch(Exceptione)

stmt=();

Stringsql=newString("

select*fromshangpin"

rs=(sql);

l=(ArrayList)MakeList(rs);

HttpSessions=();

("

l);

).forward(request,response);

}

publicList<

Product>

MakeList(ResultSetrs)throwsSQLException

List<

l=newArrayList<

();

while())

Productp=newProduct

(1),

(2),(3));

(p);

returnl;

publicvoidinit()throwsServletException{

}

2)QueryServlet代码:

publicvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)

throwsServletException,IOException{

id=("

name=("

a=("

if(a==null||("

))

num=0;

elsenum=(a);

if(id!

=null&

!

("

QueryById(request,response,id);

elseif(name!

QueryB

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 考试认证 > 司法考试

copyright@ 2008-2022 冰豆网网站版权所有

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