📄 manageaction.java
字号:
try {
//上传图片
// 新建�?个SmartUpload对象
SmartUpload su = new SmartUpload();
// 上传初始�?
su.initialize(request.getSession().getServletContext(),
(HttpServletRequest) request,
(HttpServletResponse) response);
// 设定上传限制
// 1.限制每个上传文件的最大长度�??
su.setMaxFileSize(1000000);
// 2.限制总上传数据的长度�?
// su.setTotalMaxFileSize(20000);
// 3.设定允许上传的文件(通过扩展名限制),仅允许doc,txt文件�?
su.setAllowedFilesList("jpg,gif,JPG,GIF");
// 4.设定禁止上传的文件(通过扩展名限制),禁止上传带有exe,bat,jsp, htm, html扩展名的文件和没有扩展名的文�? �?
// su.setDeniedFilesList("exe,bat,jsp,htm,html,,");
// 上传文件
su.upload();
// 将上传文件全部保存到指定目录
su.save("/images/logoes");
// 逐一提取上传文件信息,同时可保存文件�?
for (int i = 0; i < su.getFiles().getCount(); i++) {
SmartFile file = su.getFiles().getFile(i);
// 若文件不存在则继�?
if (file.isMissing()) {
continue;
}
//得到文件�?
String fileName = su.getFileNames()[i];
//生成缩小图片
ImgUtil iutil = new ImgUtil();
String tfileName = fileName.substring(0, fileName.indexOf(".")) +
"_s." + file.getFileExt();
iutil.reduce(getServlet().getServletContext().getRealPath("/") +
fileName,
getServlet().getServletContext().getRealPath("/") +
tfileName, 85, 18);
//删除原文�?
File f = new File(getServlet().getServletContext().getRealPath(
"/") +
fileName);
f.delete();
new GoodsMgr().updateBrandLogo1(BaseUtil.toInt(su.getRequest().
getParameter("brand_id")), tfileName);
}
} catch (Exception ex) {
throw new AppException(ex);
}
return mapping.findForward("doLogo1Modify");
}
public ActionForward toLogo2Modify(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
GenericVO bvo = new GoodsMgr().getBrandDetail(BaseUtil.toInt(request.
getParameter("brand_id")));
request.setAttribute("bean", bvo);
return mapping.findForward("toLogo2Modify");
}
public ActionForward doLogo2Modify(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
try {
//上传图片
// 新建�?个SmartUpload对象
SmartUpload su = new SmartUpload();
// 上传初始�?
su.initialize(request.getSession().getServletContext(),
(HttpServletRequest) request,
(HttpServletResponse) response);
// 设定上传限制
// 1.限制每个上传文件的最大长度�??
su.setMaxFileSize(1000000);
// 2.限制总上传数据的长度�?
// su.setTotalMaxFileSize(20000);
// 3.设定允许上传的文件(通过扩展名限制),仅允许doc,txt文件�?
su.setAllowedFilesList("jpg,gif,JPG,GIF");
// 4.设定禁止上传的文件(通过扩展名限制),禁止上传带有exe,bat,jsp, htm, html扩展名的文件和没有扩展名的文�? �?
// su.setDeniedFilesList("exe,bat,jsp,htm,html,,");
// 上传文件
su.upload();
// 将上传文件全部保存到指定目录
su.save("/images/logoes");
// 逐一提取上传文件信息,同时可保存文件�?
for (int i = 0; i < su.getFiles().getCount(); i++) {
SmartFile file = su.getFiles().getFile(i);
// 若文件不存在则继�?
if (file.isMissing()) {
continue;
}
//得到文件�?
String fileName = su.getFileNames()[i];
//生成缩小图片
ImgUtil iutil = new ImgUtil();
String tfileName = fileName.substring(0, fileName.indexOf(".")) +
"_s." + file.getFileExt();
iutil.reduce(getServlet().getServletContext().getRealPath("/") +
fileName,
getServlet().getServletContext().getRealPath("/") +
tfileName, 140, 30);
//删除原文�?
File f = new File(getServlet().getServletContext().getRealPath(
"/") +
fileName);
f.delete();
new GoodsMgr().updateBrandLogo2(BaseUtil.toInt(su.getRequest().
getParameter("brand_id")), tfileName);
}
} catch (Exception ex) {
throw new AppException(ex);
}
return mapping.findForward("doLogo2Modify");
}
//用户
public ActionForward toUserManage(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
//设置查询条件
GenericVO gvo = new GenericVO();
ListVO lvo = new ListVO();
gvo = AppUtil.convertParameters(request, gvo); //将request 中的参数设置到cvo\uFFFD?
lvo.setItemsPerPage(30);
lvo = AppUtil.processListVO(lvo, request); //设置ListVO
gvo.setListVO(lvo);
//查询数据
lvo = new UserMgr().searchUser(gvo);
gvo.setListVO(lvo);
//设置页面数据
request.setAttribute("bean", gvo);
return mapping.findForward("toUserManage");
}
//公告
public ActionForward toBulletinManage(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
return mapping.findForward("toBulletinManage");
}
public ActionForward toBulletinEditor(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
File f = new File(getServlet().getServletContext().getRealPath("/") +
"htmlet/bulletin.htm");
if (!f.exists()) {
f.createNewFile();
}
//读取公告文件
BufferedReader br = new BufferedReader(new InputStreamReader(new
FileInputStream(getServlet().getServletContext().getRealPath(
"/") +
"htmlet/bulletin.htm"), "UTF-8"));
String data = null;
String content = "";
while ((data = br.readLine()) != null) {
content = content + data;
}
br.close();
request.setAttribute("CONTENT", content);
return mapping.findForward("toBulletinEditor");
}
public ActionForward doBulletinModify(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
String content = request.getParameter("content");
OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(
getServlet().getServletContext().getRealPath("/") +
"htmlet/bulletin.htm"), "UTF-8");
osw.write(content, 0, content.length());
osw.flush();
osw.close();
return mapping.findForward("doBulletinModify");
}
//排行�?
public ActionForward toTopManage(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
Vector r = new GoodsMgr().getTopByType(0);
//得到每个排行榜的内容
GenericVO tvo = null;
String fileName = null;
File f = null;
for (int i = 0; i < r.size(); i++) {
tvo = (GenericVO) r.elementAt(i);
fileName = getServlet().getServletContext().getRealPath("/") +
"htmlet/top_" + tvo.getItem("TOP_ID") + ".htm";
f = new File(fileName);
if (!f.exists()) {
f.createNewFile();
}
//读取排行榜文�?
BufferedReader br = new BufferedReader(new InputStreamReader(new
FileInputStream(fileName), "UTF-8"));
String data = null;
String content = "";
while ((data = br.readLine()) != null) {
content = content + data;
}
br.close();
tvo.add("CONTENT", content);
}
request.setAttribute("RESULT", r);
return mapping.findForward("toTopManage");
}
public ActionForward toTopAdd(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
return mapping.findForward("toTopAdd");
}
public ActionForward doTopAdd(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
GenericVO gvo = new GenericVO();
gvo = AppUtil.convertParameters(request, gvo); //将request 中的参数设置到cvo
new GoodsMgr().addTop(gvo);
return mapping.findForward("doTopAdd");
}
public ActionForward toTopModify(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
GenericVO tvo = new GoodsMgr().getTopDetail(BaseUtil.toInt(request.
getParameter("top_id")));
request.setAttribute("bean", tvo);
return mapping.findForward("toTopModify");
}
public ActionForward doTopModify(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
GenericVO gvo = new GenericVO();
gvo = AppUtil.convertParameters(request, gvo); //将request 中的参数设置到cvo
new GoodsMgr().modifyTop(gvo);
this.genIndexTop();
return mapping.findForward("doTopModify");
}
public ActionForward doTopDelete(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
new GoodsMgr().deleteTop(BaseUtil.toInt(request.getParameter("top_id")));
this.genIndexTop();
return mapping.findForward("doTopDelete");
}
public ActionForward toTopEdit(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
return mapping.findForward("toTopEdit");
}
public ActionForward doTopEdit(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
Exception {
String fileName = getServlet().getServletContext().getRealPath("/") +
"htmlet/top_" + request.getParameter("top_id") +
".htm";
String content =
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">" +
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -