?? modify_ware_save.jsp
字號:
<%@ page contentType="text/html; charset=gb2312" language="java"%>
<%@ page import="com.jspsmart.upload.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>歡迎光臨網上商城</title>
<link rel=stylesheet type=text/css href="../lib/ware.css">
<jsp:useBean scope="page" id="Ware" class="com.chapter14.Ware" />
</head>
<body bgcolor="#F4FFFE">
<div align=center>
<%
try
{
// 新建一個SmartUpload對象
SmartUpload su = new SmartUpload();
// 上傳初始化
su.initialize(pageContext);
//設定上傳限制
//限制每個上傳文件的最大長度。
su.setMaxFileSize(1000000*8);
//設定允許上傳的文件(通過擴展名限制)
su.setAllowedFilesList("jpg,gif,bmp,JPG,GIF,BMP,png,PNG");
// 上傳文件
su.upload();
String sWareID=su.getRequest().getParameter("WareID");
long lWareID = Long.parseLong(sWareID);
Ware.init();
String sSortID=su.getRequest().getParameter("SortID");
long lSortID = Long.parseLong(sSortID);
String sWareName=su.getRequest().getParameter("WareName");
String sAddr=su.getRequest().getParameter("Addr");
String sIntro=su.getRequest().getParameter("Intro");
String sCompany=su.getRequest().getParameter("Company");
String sPrice=su.getRequest().getParameter("Price");
float fPrice = Float.parseFloat(sPrice);
String sPicUrl=Ware.getPicUrl();
//判斷是否有附件上傳
com.jspsmart.upload.File file = su.getFiles().getFile(0);
if (!file.isMissing())
{
String sPic=file.getFileName();
//將附件以 當前時間+附件擴展名 作為文件名保存
java.text.SimpleDateFormat dateFormatter = new java.text.SimpleDateFormat("yyyyMMddHHmmss");
String sNowTime = dateFormatter.format(new java.util.Date());
sPicUrl = sNowTime+"."+ file.getFileExt();
file.saveAs("./pic/"+sPicUrl);
}
//將文章信息保存到數據庫中
Ware.setWareID(lWareID);
Ware.setWareName(sWareName);
Ware.setCompany(sCompany);
Ware.setIntro(sIntro);
Ware.setSortID(lSortID);
Ware.setAddr(sAddr);
Ware.setPicUrl(sPicUrl);
Ware.setPrice(fPrice);
if(Ware.modify())
{
out.println("<p><font color=blue>商品信息修改成功</font></p>");
out.println("<input type=button name=btn1 value=\"返回商品管理\" onClick='window.location=\"./ware_management.jsp\"'>");
}
else
{
out.println("<p><font color=red>商品信息修改失敗,請重試</font></p>");
out.println("<input type=button name=btn2 value=\"返回\" onClick='window.history.go(-1)'>");
return;
}
}
catch(Exception e)
{
out.println("<p><font color=red>您上傳的文件格式不對,或者上傳文件太大!</font></p>");
out.println("<input type=button name=btn3 value=返回 onClick='window.history.go(-1)'>");
return;
}
%>
</div>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -