?? modify_notice_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/enterprise.css">
<jsp:useBean scope="page" id="Notice" class="com.chapter15.Notice" />
</head>
<body bgcolor="#F2F2F2">
<div align="center"><br>
<%
try
{
//新建一個SmartUpload對象
SmartUpload su = new SmartUpload();
//上傳初始化
su.initialize(pageContext);
//設定上傳限制
//限制上傳文件的最大長度。
su.setMaxFileSize(10000000*8);
//上傳文件
su.upload();
//獲取公告信息
String sSubject=su.getRequest().getParameter("Subject");
String sContent=su.getRequest().getParameter("Content");
String sNoticeID=su.getRequest().getParameter("NoticeID");
long lNoticeID=Long.parseLong(sNoticeID);
String strPage=su.getRequest().getParameter("showPage");
String sAttachment="";
String sFileUrl="";
long lUserID = (Long) session.getAttribute("UserID");
//判斷是否有附件上傳
com.jspsmart.upload.File file = su.getFiles().getFile(0);
if (!file.isMissing())
{
sAttachment=file.getFileName();
//將附件以 當前時間+附件擴展名 作為文件名保存
java.text.SimpleDateFormat dateFormatter = new java.text.SimpleDateFormat("yyyyMMddHHmmss");
String sNowTime = dateFormatter.format(new java.util.Date());
sFileUrl = sNowTime+"."+ file.getFileExt();
file.saveAs("./notice_attachment/"+sFileUrl);
}
//獲取當前公告的原來信息
Notice.setNoticeID(lNoticeID);
Notice.init();
//將公告信息保存到數據庫中
Notice.setSubject(sSubject);
Notice.setContent(sContent);
Notice.setFileUrl(sFileUrl);
Notice.setAttachment(sAttachment);
Notice.setUserID(lUserID);
if(Notice.modify())
{
out.println("<p><font color=blue>修改公告信息成功</font></p>");
out.println("<div><input type=button Subject=btn value=\"返回公告管理\" onClick='window.location=\"./notice_management.jsp?showPage="+strPage+"\"'></div>");
}
else
{
out.println("<p><font color=red>修改公告信息失敗,請重試</font></p>");
out.println("<div><input type=button Subject=btn value=\"返回\" onClick='window.history.go(-1)'></div>");
return;
}
}
catch(Exception e)
{
out.println("<p><font color=red>您上傳的文件太大!</font></p>");
out.println("<div><input type=button Subject=btn value=返回 onClick='window.history.go(-1)'></div>");
return;
}
%>
</div>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -