productedInsert.jsp
资源名称:shop.rar [点击查看]
上传用户:yatiankong
上传日期:2014-05-16
资源大小:5604k
文件大小:4k
源码类别:
Applet
开发平台:
Java
- <%@ page contentType="text/html; charset=GB2312"%>
- <%@ page import="java.sql.*,com.jspsmart.upload.*"%>
- <%@ page import="java.sql.* ,java.util.Date,java.text.SimpleDateFormat"%>
- <jsp:useBean id="file_Bean" class="MyFly.Bean.file_Bean" scope="request"/>
- <jsp:useBean id="useclassBean" class="MyFly.Bean.useclassBean" scope="request"/>
- <jsp:useBean id="characterclassBean" class="MyFly.Bean.characterclassBean" scope="request"/>
- <jsp:useBean id="productinfoBean" class="MyFly.Bean.productinfoBean" scope="request"/>
- <%!
- String fun(String str)
- {
- try
- {
- return new String(str.getBytes("ISO8859_1"));
- }
- catch(Exception e)
- {
- return "";
- }
- }
- %>
- <html>
- <body>
- <%
- try{
- String str=request.getRealPath("/");
- str+="\XKB\product_image";
- SmartUpload mySmartUpload=new SmartUpload();
- mySmartUpload.initialize(pageContext);
- mySmartUpload.setTotalMaxFileSize(20000000);
- mySmartUpload.upload();
- //int count;
- //count=mySmartUpload.save("/XKB/product_image");
- String productID=mySmartUpload.getRequest().getParameter("productID");
- productinfoBean.setProductID(productID);
- String productName=mySmartUpload.getRequest().getParameter("productName");
- productinfoBean.setProductName(productName);
- String useclassID=mySmartUpload.getRequest().getParameter("useclassID");
- productinfoBean.setUseclassID(Integer.parseInt(useclassID));
- String characterID=mySmartUpload.getRequest().getParameter("characterID");
- productinfoBean.setCharacterID(Integer.parseInt(characterID));
- String marketPrice=mySmartUpload.getRequest().getParameter("marketPrice");
- productinfoBean.setMarketPrice(Float.parseFloat(marketPrice));
- String preferPrice=mySmartUpload.getRequest().getParameter("preferPrice");
- productinfoBean.setPreferPrice(Float.parseFloat(preferPrice));
- SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-dd");//将显示"1999-10-1 21:03:10"的格式.
- Date currentTime_1 = new Date();
- String appendTime = formatter.format(currentTime_1);
- productinfoBean.setShangData(appendTime);
- String storage=mySmartUpload.getRequest().getParameter("storage");
- productinfoBean.setStorage(Integer.parseInt(storage));
- com.jspsmart.upload.File maxpic=mySmartUpload.getFiles().getFile(0);
- String max=maxpic.getFileName();
- String maxFile="max"+max;
- file_Bean.setPathName(str);
- String maxName=file_Bean.getFileName(maxFile);
- productinfoBean.setMaxPicture(maxName);
- com.jspsmart.upload.File minpic=mySmartUpload.getFiles().getFile(1);
- String min=minpic.getFileName();
- String minFile="min"+min;
- file_Bean.setPathName(str);
- String minName=file_Bean.getFileName(minFile);
- productinfoBean.setMinPicture(minName);
- String introduce=mySmartUpload.getRequest().getParameter("content");
- productinfoBean.setIntroduce(introduce);
- String publish=mySmartUpload.getRequest().getParameter("publish");//???
- productinfoBean.setPublish(publish);
- String author=mySmartUpload.getRequest().getParameter("author");//??
- productinfoBean.setAuthor(author);
- //System.out.print(author);
- String tuijian=mySmartUpload.getRequest().getParameter("tuijian");
- if(tuijian==null)
- {
- productinfoBean.setTuijian(0);
- }
- else
- {
- productinfoBean.setTuijian(1);
- }
- String isnew=mySmartUpload.getRequest().getParameter("isnew");//?????
- if(isnew==null)
- {
- productinfoBean.setIsnew(0);
- }
- else
- {
- productinfoBean.setIsnew(1);
- }
- if(productinfoBean.addNew()==0)
- {
- out.println("<Script language=JavaScript>alert('添加失败');javascript:history.back();</Script>");
- }
- else
- {
- maxpic.saveAs("/XKB/product_image/" + maxName);
- minpic.saveAs("/XKB/product_image/" + minName);
- response.sendRedirect("produceinfoView.jsp?success=true");
- }
- }
- catch(Exception e)
- {
- out.println("<Script language=JavaScript>alert('添加失败');javascript:history.back();</Script>");
- }
- %>
- </body>
- </html>