制作一个简单的电子商务网站Word下载.docx
- 文档编号:18423219
- 上传时间:2022-12-16
- 格式:DOCX
- 页数:32
- 大小:221.75KB
制作一个简单的电子商务网站Word下载.docx
《制作一个简单的电子商务网站Word下载.docx》由会员分享,可在线阅读,更多相关《制作一个简单的电子商务网站Word下载.docx(32页珍藏版)》请在冰豆网上搜索。
LastName
EmailAddress
2)安装所需的第三方软件包
在testapp/WEB-INF新建lib目录,并将以下需要的第三方软件包拷贝到lib目录下:
jstl.jar、standard.jar、mysql-connector-java-5.0.7-bin.jar。
3)配置JDBC数据源
web.xml页面类容如下:
<
?
xmlversion="
1.0"
encoding="
ISO-8859-1"
>
web-appxmlns="
xmlns:
xsi="
http:
//www.w3.org/2001/XMLSchema-instance"
xsi:
schemaLocation="
version="
2.5"
!
--UsedbytheJSTLdatabaseactions-->
context-param>
param-name>
javax.servlet.jsp.jstl.sql.dataSource<
/param-name>
param-value>
jdbc:
mysql:
//localhost:
3306/homeworks?
user=root&
amp;
password=root,com.mysql.jdbc.Driver
/param-value>
/context-param>
description>
ServletandJSPExamples.
/description>
display-name>
ServletandJSPExamples<
/display-name>
servlet>
servlet-name>
Test<
/servlet-name>
AtestServlet<
servlet-class>
test.ServletTest<
/servlet-class>
/servlet>
servlet-mapping>
url-pattern>
/Test<
/url-pattern>
/servlet-mapping>
/web-app>
4)建立和信息录入相关的JSP页面
Index.jsp:
网站首页
html>
head>
title>
SearchinUserDatabase<
/title>
/head>
bodybgcolor="
white"
Welcometomywebsitehomepage
p>
ifyouareamemberpleaseclicklogin
ifnotthenclickontheregistration
br/>
ahref="
register.jsp"
inputtype="
button"
value="
registration"
/>
/a>
login.jsp"
login"
/body>
/html>
register.jsp:
用于注册用户信息的录入。
%@pagecontentType="
text/html"
%>
%@taglibprefix="
c"
uri="
fn"
UserEntryForm<
body>
RegisteredUserInterface
Pleaseenterinformationaboutauserbelow:
formaction="
validate.jsp"
method="
post"
table>
tr>
td>
LoginName:
/td>
text"
name="
loginName"
value="
${fn:
escapeXml(param.loginName)}"
escapeXml(loginNameError)}<
/tr>
Password:
password"
escapeXml(param.password)}"
escapeXml(passwordError)}<
FirstName:
firstName"
escapeXml(param.firstName)}"
escapeXml(firstNameError)}<
LastName:
lastName"
escapeXml(param.lastName)}"
escapeXml(lastNameError)}<
EmailAddress:
emailAddress"
escapeXml(param.emailAddress)}"
escapeXml(emailAddressError)}<
(Useformat****************)<
tdcolspan=2>
submit"
Submit"
/table>
/form>
validate.jsp:
用于验证录入的用户信息
程序代码如下:
fmt"
c:
setvar="
isValid"
true"
iftest="
${emptyparam.loginName}"
loginNameError"
scope="
request"
Loginmissing"
false"
/c:
if>
${emptyparam.password}"
passwordError"
Passwordmissing"
${emptyparam.firstName}"
firstNameError"
FirstNamemissing"
${emptyparam.lastName}"
lastNameError"
LastNamemissing"
${emptyparam.emailAddress}"
emailAddressError"
EmailAddressmissing"
choose>
whentest="
${isValid}"
jsp:
forwardpage="
store.jsp"
when>
otherwise>
store.jsp:
用于将录入的信息保存到数据库中。
sql"
%--
Seeiftheuserisalreadydefined.Ifnot,insertthe
info,elseupdateit.
--%>
sql:
queryvar="
user"
SELECT*FROMUser
WHERELoginName=?
paramvalue="
${param.loginName}"
/sql:
query>
Dealwiththedatevalues:
parsetheregisterdateandcreateaDate
objectfromit,andcreateanewvariabletoholdthecurrentdate.
fmt:
parseDatevalue="
${param.registerDate}"
var="
parsedRegisterDate"
pattern="
yyyy-MM-dd"
useBeanid="
now"
class="
java.util.Date"
${user.rowCount==0}"
update>
INSERTINTOUser
(LoginName,Password,FirstName,LastName,EmailAddress)
VALUES(?
?
)
${param.password}"
${param.firstName}"
${param.lastName}"
${param.emailAddress}"
UPDATEUser
SETPassword=?
FirstName=?
LastName=?
EmailAddress=?
%--Gettheneworupdateddatafromthedatabase--%>
newUserInfo"
session"
%--Redirecttotheconfirmationpage--%>
redirecturl="
confirmation.jsp"
confirmation.jsp:
用于显示已保存到数据的信息。
UserInfoStored<
get"
Thisistheinformationstoredinthehomeworksdatabase:
forEachitems="
${newUserInfo.rows}"
row"
${row}"
column"
tdalign=right>
b>
escapeXml(column.key)}:
/b>
escapeXml(column.value)}
forEach>
GoBack"
二、用户登陆
login.jsp注册用户登陆界面
RegisteredusersLandingInterface
find.jsp"
loginName:
Password"
escapeXml(param.Password)}"
Find.jsp在数据库中检索登陆界面所录入的信息
Executequery,withwildcardcharactersaddedtothe
parametervaluesusedinthesearchcriteria
userList"
SELECTloginName,PasswordFROMUser
WHEREloginNameLIKE?
ANDPasswordLIKE?
ORDERBYloginName
%${param.loginName}%"
%${param.Password}%"
list.jsp"
List.jsp显示用户登陆界面
Result<
${userList.rowCount==0}"
Sorry,nouserwerefound.
Welcometotheuser:
thead>
/thead>
${userList.rows}"
escapeXml(row.loginName)}<
P>
NextYoucouldmanagementbooksinformation
bookindex.jsp"
BooksManagement"
三、商品信息
在数据库homeworks中建立表books其内容如下:
Name
Price
Bookindex书籍管理首页
ManagementBooksInformation
IFyouwanttoaddbooksinfomationandupdatapleasecheckAddBook
IFyouwanttoManagementbooksinfomationpleasecheckManagement
addbooks.jsp"
AddBook"
sea
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 制作 一个 简单 电子商务 网站