当前位置:Gxlcms > 数据库问题 > 商城项目整理(四)JDBC+富文本编辑器实现商品增加,样式设置,和修改

商城项目整理(四)JDBC+富文本编辑器实现商品增加,样式设置,和修改

时间:2021-07-01 10:21:17 帮助过:15人阅读

create table TEST.GOODS_TABLE 2 ( 3 gid NUMBER not null, 4 gname VARCHAR2(90), 5 gdetails CLOB, 6 gpicture VARCHAR2(100), 7 gprice NUMBER, 8 gleixing NUMBER, 9 gpinpai VARCHAR2(20) 10 ) 11 tablespace USERS 12 pctfree 10 13 initrans 1 14 maxtrans 255 15 storage 16 ( 17 initial 64K 18 next 1M 19 minextents 1 20 maxextents unlimited 21 ); 22 comment on column TEST.GOODS_TABLE.gid 23 is 商品ID; 24 comment on column TEST.GOODS_TABLE.gname 25 is 商品名称; 26 comment on column TEST.GOODS_TABLE.gdetails 27 is 商品详情; 28 comment on column TEST.GOODS_TABLE.gpicture 29 is 商品图片; 30 comment on column TEST.GOODS_TABLE.gprice 31 is 商品价格; 32 comment on column TEST.GOODS_TABLE.gleixing 33 is 商品类型; 34 comment on column TEST.GOODS_TABLE.gpinpai 35 is 商品品牌; 36 alter table TEST.GOODS_TABLE 37 add constraint PK_GOODSID primary key (GID) 38 using index 39 tablespace USERS 40 pctfree 10 41 initrans 2 42 maxtrans 255 43 storage 44 ( 45 initial 64K 46 next 1M 47 minextents 1 48 maxextents unlimited 49 );

商品类:

 1 package com.hanqi.model;
 2 
 3 import java.sql.Clob;
 4 
 5 //商品类
 6 public class Goods {
 7     
 8     private Integer gid;//商品ID
 9 
10     private String gname;//商品名称
11     private String gdetails;//商品详情
12     private String gpicture;//商品图片
13     private int gprice;//商品价格
14     private int gleixing;//商品类型
15     private String gpinpai;//商品品牌
16     
17     public Goods() {
18         super();
19         // TODO Auto-generated constructor stub
20     }
21     public Goods(Integer gid, String gname, String gdetails, String gpicture, int gprice, int gleixing, String gpinpai) {
22         super();
23         this.gid = gid;
24         this.gname = gname;
25         this.gdetails = gdetails;
26         this.gpicture = gpicture;
27         this.gprice = gprice;
28         this.gleixing = gleixing;
29         this.gpinpai = gpinpai;
30     }
31     
32     public Integer getGid() {
33         return gid;
34     }
35     public void setGid(Integer gid) {
36         this.gid = gid;
37     }
38     public String getGname() {
39         return gname;
40     }
41     public void setGname(String gname) {
42         this.gname = gname;
43     }
44     public String getGdetails() {
45         return gdetails;
46     }
47     public void setGdetails(String gdetails) {
48         this.gdetails = gdetails;
49     }
50     public String getGpicture() {
51         return gpicture;
52     }
53     public void setGpicture(String gpicture) {
54         this.gpicture = gpicture;
55     }
56     public int getGprice() {
57         return gprice;
58     }
59     public void setGprice(int gprice) {
60         this.gprice = gprice;
61     }
62     public int getGleixing() {
63         return gleixing;
64     }
65     public void setGleixing(int gleixing) {
66         this.gleixing = gleixing;
67     }
68     public String getGpinpai() {
69         return gpinpai;
70     }
71     public void setGpinpai(String gpinpai) {
72         this.gpinpai = gpinpai;
73     }
74     @Override
75     public String toString() {
76         return "Goods [gid=" + gid + ", gname=" + gname + ", gdetails=" + gdetails + ", gpicture=" + gpicture
77                 + ", gprice=" + gprice + ", gleixing=" + gleixing + ", gpinpai=" + gpinpai + "]";
78     }
79 }

JSP主页,包含引入的富文本编辑器和商品增加模块,easyui搭建:

  1 <%@ page language="java" contentType="text/html; charset=UTF-8"
  2     pageEncoding="UTF-8"
  3     import="com.hanqi.model.Log,java.net.UnknownHostException,java.net.InetAddress,java.util.*,com.hanqi.dal.MethodDal"%>
  4 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  5 <html>
  6 <head>
  7 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  8 <script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
  9 <script type="text/javascript"
 10     src="jquery-easyui-1.5.1/jquery.easyui.min.js"></script>
 11     <link rel="shortcut icon" href="img/logo1.jpg"/>
 12 <link type="text/css" rel="stylesheet"
 13     href="jquery-easyui-1.5.1/themes/icon.css"></link>
 14 <link type="text/css" rel="stylesheet"
 15     href="jquery-easyui-1.5.1/themes/default/easyui.css"></link>
 16 <script type="text/javascript"
 17     src="jquery-easyui-1.5.1/locale/easyui-lang-zh_CN.js"></script>
 18 <title>商城后台管理</title>
 19 
 20 <!-- <script type="text/javascript" src="js/index.js"></script> -->
 21 <style type="text/css">
 22 .datagrid-btable tr {
 23     height: 30px;
 24 }
 25 </style>
 26 </head>
 27     <%
 28     //验证session,防止直接进入该页面
 29     request.setCharacterEncoding("utf-8");
 30     response.setCharacterEncoding("utf-8");
 31     response.setContentType("text/html; charset=utf-8");
 32     
 33     Object obj = request.getSession().getAttribute("admin");//获取session对象
 34     
 35     if(obj == null) {
 36         response.sendRedirect("h_login_j.jsp");
 37     }  
 38     
 39     %>
 40 <%    //访问后台主页写入日志
 41     Object o=session.getAttribute("log");
 42     if(o==null){
 43         Log log = new Log();
 44         log.setPname("admin");
 45         log.setPugroup("超级管理员");
 46         InetAddress address = null;
 47         Date date = new Date();
 48         log.setPuptime(date.toLocaleString());
 49         try {
 50             address = InetAddress.getLocalHost();
 51         } catch (UnknownHostException e) {
 52             // TODO Auto-generated catch block
 53             e.printStackTrace();
 54         }
 55         log.setPip(address.getHostAddress());
 56         log.setPlog("后台主页");
 57         MethodDal m = new MethodDal();
 58         m.insertLog(log);
 59         session.setAttribute("log", log);
 60     }
 61     
 62 %>
 63 <body class="easyui-layout">
 64     <!-- 添加商品 -->
 65     <div data-options="region:‘north‘,split:true"
 66         style="height: 50px; background-color: cornflowerblue">
 67         <span style="height: 40px; line-height: 40px; vertical-align: center;">登录用户:<%
 68      Log l = (Log) session.getAttribute("log");
 69      out.print(l.getPname());
 70  %>&nbsp;|&nbsp;用户组:<%=l.getPugroup()%>&nbsp;|&nbsp;登录时间:<%=l.getPuptime()%>
 71             &nbsp;|&nbsp; 当前IP:<%=l.getPip()%>
 72         </span><br>
 73     </div>
 74     <!-- 对话框开始 -->
 75     <div data-options="region:‘center‘,split:true"
 76         style="padding: 5px; background: #eee">
 77         <div id="tabs" class="easyui-tabs" style="width: 100%; height: 100%;">
 78             <div title="主页" style="">
 79                 <table id="dg"></table>
 80                 <!-- 商品的表单 -->
 81                 <div id="zhong" style="display: none">
 82                     <form id="addGood" method="post"
 83                         style="width: 600px; padding: 20px">
 84                         商品名称:<input  name="gname" class="tb easyui-validatebox" type="text"
 85                             style="width: 200px"> <span style="margin-left: 50px">商品价格:</span><input  id="jiage"
 86                             name="gprice" class="tb easyui-numberbox" type="text" style="width: 150px;"><br>
 87                         商品品牌:<input name="gpinpai" class="tb easyui-validatebox" type="text"
 88                             style="width: 200px; margin-top: 10px"> <span
 89                             style="margin-left: 50px">商品类型:</span>
 90                             <input id="gleixing" style="width: 150px;"  class="easyui-combobox" name="gleixing"   
 91     data-options="valueField:‘id‘,textField:‘text‘,url:‘opdata.json‘" /> 
 92         <!-- <input name="gleixing" class="tb easyui-validatebox" type="text" style="width: 150px; margin-top: 10px"> -->
 93     <br>
 94                         商品图片:<input name="gpricture" class="tb" type="file"
 95                             style="width: 200px; margin-top: 10px"><br>
 96                         <!-- 加载编辑器的容器 -->
 97                         <script id="container" name="content" type="text/plain"
 98                             imagePathFormat="/upload/">
 99                              请输入商品描述
100                         </script>
101                         <input type="submit" name="" id="" value="提交" />
102                         <input type="reset" value="重置">
103                     </form>
104                 </div>
105                 <!-- 商品的表单 -->
106                 <div id="gai" style="display: none">
107                     <!-- <div id="gai" class="easyui-dialog" data-options="closed:true"> -->
108                     <form id="fromgai" action="GaiGoodsGoodst" method="post"
109                         style="width: 600px; padding: 20px">
110                         商品名称:<input name="gname" class="tb" type="text"
111                             style="width: 200px"> <span style="margin-left: 50px">商品价格:</span><input
112                             name="gprice" class="tb" type="text" style="width: 150px;"><br>
113                         商品品牌:<input name="gpinpai" class="tb" type="text"
114                             style="width: 200px; margin-top: 10px"> <span
115                             style="margin-left: 50px">商品类型:</span><input name="gleixing"
116                             class="tb" type="text" style="width: 150px"><br>
117                         商品图片:<input name="gpicture" class="tb" type="text"
118                             style="width: 200px; margin-top: 10px"><br> <input
119                             name="xpricture" class="tb" type="file"
120                             style="width: 200px; margin-top: 10px"><br>
121                         <!-- 加载编辑器的容器 -->
122                         <template> <input type="text" name="gdetails" id="" />
123                         </template>
124                         <script id="container1" name="gdetails" type="text/plain"
125                             imagePathFormat="/upload/">
126                               
127                         </script>
128                         <input type="submit" name="" id="" value="提交" />
129                     </form>
130                 </div>
131             </div>
132         </div>
133     </div>
134     <!-- 对话框结束 -->
135     <!-- 目录开始 -->
136     <div data-options="region:‘west‘,split:true" width=210>
137         <div id="aa" class="easyui-accordion"
138             style="width: 200px; height: 543px">
139             <div title="商品管理" style="overflow: auto; padding: 10px">
140                 <ul>
141                     <li class="lis"><a href="#" class="easyui-linkbutton ab abc"
142                         plain="true">添加商品</a></li>
143                     <li class="lis"><a href="#" class="easyui-linkbutton ab"
144                         plain="true">待引进商品</a></li>
145                     <li class="lis"><a href="#" class="easyui-linkbutton ab"
146                         plain="true">待审核商品</a></li>
147                 </ul>
148             </div>
149             <div title="订单管理" style="overflow: auto; padding: 10px">
150                 <ul>
151                     <li class="lis"><a href
                        
                    

人气教程排行