├── .idea
├── artifacts
│ └── BookStore_war_exploded.xml
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── dataSources.local.xml
├── dataSources.xml
├── dataSources
│ └── 9029fc5d-64eb-4bf8-9be8-b6636696dd9b.xml
├── misc.xml
├── modules.xml
├── uiDesigner.xml
├── vcs.xml
└── workspace.xml
├── BookStore.iml
├── README.md
├── SQL
└── Product.sql
├── out
└── artifacts
│ └── BookStore_war_exploded
│ ├── WEB-INF
│ ├── classes
│ │ └── com
│ │ │ ├── dao
│ │ │ ├── DBUtil.class
│ │ │ └── ProductDao.class
│ │ │ ├── entity
│ │ │ ├── Product.class
│ │ │ └── User.class
│ │ │ ├── filter
│ │ │ └── EncodingFilter.class
│ │ │ ├── service
│ │ │ └── ProductService.class
│ │ │ └── servlet
│ │ │ ├── AddServlet.class
│ │ │ ├── BuyServlet.class
│ │ │ ├── CheckOutServlet.class
│ │ │ ├── DeleteServlet.class
│ │ │ ├── LoginServlet.class
│ │ │ └── PageServlet.class
│ ├── lib
│ │ └── mysql-connector-java-5.1.40-bin.jar
│ └── web.xml
│ ├── cart.jsp
│ ├── checkout.jsp
│ ├── image
│ ├── book.png
│ └── checkout.png
│ ├── index.jsp
│ └── product.jsp
├── src
└── com
│ ├── dao
│ ├── DBUtil.java
│ └── ProductDao.java
│ ├── entity
│ ├── Product.java
│ └── User.java
│ ├── filter
│ └── EncodingFilter.java
│ ├── service
│ └── ProductService.java
│ └── servlet
│ ├── AddServlet.java
│ ├── BuyServlet.java
│ ├── CheckOutServlet.java
│ ├── DeleteServlet.java
│ ├── LoginServlet.java
│ └── PageServlet.java
└── web
├── WEB-INF
├── classes
│ └── com
│ │ ├── dao
│ │ ├── DBUtil.class
│ │ └── ProductDao.class
│ │ ├── entity
│ │ ├── Product.class
│ │ └── User.class
│ │ ├── filter
│ │ └── EncodingFilter.class
│ │ ├── service
│ │ └── ProductService.class
│ │ └── servlet
│ │ ├── AddServlet.class
│ │ ├── BuyServlet.class
│ │ ├── CheckOutServlet.class
│ │ ├── DeleteServlet.class
│ │ ├── LoginServlet.class
│ │ └── PageServlet.class
├── lib
│ └── mysql-connector-java-5.1.40-bin.jar
└── web.xml
├── cart.jsp
├── checkout.jsp
├── image
├── book.png
└── checkout.png
├── index.jsp
└── product.jsp
/.idea/artifacts/BookStore_war_exploded.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | $PROJECT_DIR$/out/artifacts/BookStore_war_exploded
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/dataSources.local.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | #@
7 | `
8 |
9 |
10 | master_key
11 | root
12 | bookstore:
13 |
14 |
15 |
--------------------------------------------------------------------------------
/.idea/dataSources.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | mysql
6 | true
7 | com.mysql.jdbc.Driver
8 | jdbc:mysql://localhost:3306/bookstore
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/dataSources/9029fc5d-64eb-4bf8-9be8-b6636696dd9b.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 1
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | 1
17 | int(11)|0
18 | 1
19 |
20 |
21 | 1
22 | varchar(100)|0
23 |
24 |
25 | 1
26 | double|0
27 |
28 |
29 | book_id
30 | 1
31 |
32 |
33 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/uiDesigner.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | -
6 |
7 |
8 | -
9 |
10 |
11 | -
12 |
13 |
14 | -
15 |
16 |
17 | -
18 |
19 |
20 |
21 |
22 |
23 | -
24 |
25 |
26 |
27 |
28 |
29 | -
30 |
31 |
32 |
33 |
34 |
35 | -
36 |
37 |
38 |
39 |
40 |
41 | -
42 |
43 |
44 |
45 |
46 | -
47 |
48 |
49 |
50 |
51 | -
52 |
53 |
54 |
55 |
56 | -
57 |
58 |
59 |
60 |
61 | -
62 |
63 |
64 |
65 |
66 | -
67 |
68 |
69 |
70 |
71 | -
72 |
73 |
74 | -
75 |
76 |
77 |
78 |
79 | -
80 |
81 |
82 |
83 |
84 | -
85 |
86 |
87 |
88 |
89 | -
90 |
91 |
92 |
93 |
94 | -
95 |
96 |
97 |
98 |
99 | -
100 |
101 |
102 | -
103 |
104 |
105 | -
106 |
107 |
108 | -
109 |
110 |
111 | -
112 |
113 |
114 |
115 |
116 | -
117 |
118 |
119 | -
120 |
121 |
122 |
123 |
124 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 | true
214 | DEFINITION_ORDER
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
435 |
436 |
437 |
438 |
439 |
440 |
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 |
449 |
450 |
451 |
452 |
453 |
454 |
455 |
456 |
457 |
458 |
459 |
460 |
461 |
462 |
463 |
464 |
465 |
466 |
467 |
468 |
469 |
470 |
471 |
472 |
473 |
474 |
475 |
476 |
477 |
478 |
479 |
480 |
481 |
482 |
483 |
484 |
485 |
486 |
487 |
488 |
489 |
490 |
491 |
492 |
493 |
494 |
495 |
496 |
497 |
498 |
499 |
500 |
501 |
502 |
503 |
504 |
505 |
506 |
507 |
508 |
509 |
510 |
511 |
512 |
513 |
514 |
515 |
516 |
517 |
518 |
519 |
520 |
521 |
522 |
523 |
524 |
525 |
526 |
527 |
528 |
529 |
530 |
531 |
532 |
533 |
534 |
535 |
536 |
537 |
538 |
539 |
540 |
541 |
542 |
543 |
544 |
545 |
546 |
547 |
548 |
549 |
550 |
551 |
552 |
553 |
554 |
555 |
556 |
557 |
558 |
559 |
560 |
561 |
562 |
563 |
564 |
565 |
566 |
567 |
568 |
569 |
570 |
571 |
572 |
573 |
574 |
575 |
576 |
577 |
578 |
579 |
580 |
581 |
582 |
583 |
584 |
585 |
586 |
587 |
588 |
589 |
590 |
591 |
592 |
593 |
594 |
595 |
596 |
597 |
598 |
599 |
600 |
601 |
602 |
603 |
604 |
605 |
606 |
607 |
608 |
609 |
610 |
611 |
612 |
613 |
614 |
615 |
616 |
617 |
618 |
619 |
620 |
621 |
622 |
623 |
624 |
625 |
626 |
627 |
628 |
629 |
630 |
631 |
632 |
633 |
634 |
635 |
636 |
637 |
638 |
639 |
640 |
641 |
642 |
643 |
644 |
645 |
646 |
647 |
648 |
649 |
650 |
651 |
652 |
653 |
654 |
655 |
656 |
657 |
658 |
659 |
660 |
661 |
662 |
663 |
664 |
665 |
666 |
667 |
668 |
669 |
670 |
671 |
672 |
673 |
674 |
675 |
676 |
677 |
678 |
679 |
680 |
681 |
682 |
683 |
684 |
685 |
686 |
687 |
688 |
689 |
690 |
691 |
692 |
693 |
694 |
695 |
696 |
697 |
698 |
699 |
700 |
701 |
702 |
703 |
704 |
705 |
706 |
707 |
708 |
709 |
710 |
711 |
712 |
713 |
714 |
715 |
716 |
717 |
718 |
719 |
720 |
721 |
722 |
723 |
724 |
725 |
726 |
727 |
728 |
729 |
730 |
731 |
732 |
733 |
734 |
735 |
736 |
737 |
738 |
739 |
740 |
741 |
742 |
743 |
744 |
745 |
746 |
747 |
748 |
749 |
750 |
751 |
752 |
753 |
754 |
755 |
756 |
757 |
758 |
759 |
760 | project
761 |
762 |
763 |
764 |
765 |
766 |
767 |
768 |
769 |
770 |
771 |
772 |
773 |
774 |
775 |
776 |
777 |
778 |
779 |
780 |
781 |
782 |
783 |
784 |
785 |
786 |
787 |
788 |
789 |
790 |
791 |
792 |
793 |
794 |
795 |
796 |
797 |
798 |
799 |
800 |
801 |
802 |
803 |
804 |
805 |
806 |
807 |
808 |
809 |
810 |
811 |
812 |
813 |
814 |
815 |
816 |
817 |
818 |
819 |
820 |
821 |
822 |
823 |
824 |
825 |
826 |
827 |
828 |
829 |
830 |
831 |
832 |
833 |
834 |
835 |
836 |
837 |
838 |
839 |
840 |
841 |
842 |
843 |
844 |
845 |
846 |
847 |
848 |
849 |
850 |
851 |
852 |
853 |
854 |
855 |
856 |
857 |
858 |
859 |
860 |
861 |
862 |
863 |
864 |
865 |
866 |
867 | 1509700768284
868 |
869 |
870 | 1509700768284
871 |
872 |
873 |
874 |
875 |
876 |
877 |
878 |
879 |
880 |
881 |
882 |
883 |
884 |
885 |
886 |
887 |
888 |
889 |
890 |
891 |
892 |
893 |
894 |
895 |
896 |
897 |
898 |
899 |
900 |
901 |
902 |
903 |
904 |
905 |
906 |
907 |
908 |
909 |
910 |
911 |
912 |
913 |
914 |
915 |
916 |
917 |
918 |
919 |
920 |
921 |
922 |
923 |
924 |
925 |
926 |
927 |
928 |
929 |
930 |
931 |
932 |
933 |
934 |
935 |
936 |
937 |
938 |
939 |
940 |
941 |
942 |
943 |
944 |
945 |
946 |
947 |
948 |
949 |
950 |
951 |
952 |
953 |
954 |
955 |
956 |
957 |
958 |
959 |
960 |
961 |
962 |
963 |
964 |
965 |
966 |
967 |
968 |
969 |
970 |
971 |
972 |
973 |
974 |
975 |
976 |
977 |
978 |
979 |
980 |
981 |
982 |
983 |
984 |
985 |
986 |
987 |
988 |
989 |
990 |
991 |
992 |
993 |
994 |
995 |
996 |
997 |
998 |
999 |
1000 |
1001 |
1002 |
1003 |
1004 |
1005 |
1006 |
1007 |
1008 |
1009 |
1010 |
1011 |
1012 |
1013 |
1014 |
1015 |
1016 |
1017 |
1018 |
1019 |
1020 |
1021 |
1022 |
1023 |
1024 |
1025 |
1026 |
1027 |
1028 |
1029 |
1030 |
1031 |
1032 |
1033 |
1034 |
1035 |
1036 |
1037 |
1038 |
1039 |
1040 |
1041 |
1042 |
1043 |
1044 |
1045 |
1046 |
1047 |
1048 |
1049 |
1050 |
1051 |
1052 |
1053 |
1054 |
1055 |
1056 |
1057 |
1058 |
1059 |
1060 |
1061 |
1062 |
1063 |
1064 |
1065 |
1066 |
1067 |
1068 |
1069 |
1070 |
1071 |
1072 |
1073 |
1074 |
1075 |
1076 |
1077 |
1078 |
1079 |
1080 |
1081 |
1082 |
1083 |
1084 |
1085 |
1086 |
1087 |
1088 |
1089 |
1090 |
1091 |
1092 |
1093 |
1094 |
1095 |
1096 |
1097 |
1098 |
1099 |
1100 |
1101 |
1102 |
1103 |
1104 |
1105 |
1106 |
1107 |
1108 |
1109 |
1110 |
1111 |
1112 |
1113 |
1114 |
1115 |
1116 |
1117 |
1118 |
1119 |
1120 |
1121 |
1122 |
1123 |
1124 |
1125 |
1126 |
1127 |
1128 |
1129 |
1130 |
1131 |
1132 |
1133 |
1134 |
1135 |
1136 |
1137 |
1138 |
1139 |
1140 |
1141 |
1142 |
1143 |
1144 |
1145 |
1146 |
1147 |
1148 |
1149 |
1150 |
1151 |
1152 |
1153 |
1154 |
1155 |
1156 |
1157 |
1158 |
1159 |
1160 |
1161 |
1162 |
1163 |
1164 |
1165 |
1166 |
1167 |
1168 |
1169 |
1170 |
1171 |
1172 |
1173 |
1174 |
1175 |
1176 |
1177 |
1178 |
1179 |
1180 |
1181 |
1182 |
1183 |
1184 |
1185 |
1186 |
1187 |
1188 |
1189 |
1190 |
1191 |
1192 |
1193 |
1194 |
1195 |
1196 |
1197 |
1198 |
1199 |
1200 |
1201 |
1202 |
1203 |
1204 |
1205 |
1206 |
1207 |
1208 |
1209 |
1210 |
1211 |
1212 |
1213 |
1214 |
1215 |
1216 |
1217 |
1218 |
1219 |
1220 |
1221 |
1222 |
1223 |
1224 |
1225 |
1226 |
1227 |
1228 |
1229 |
1230 |
1231 |
1232 |
1233 |
1234 |
1235 |
1236 |
1237 |
1238 |
1239 |
1240 |
1241 |
1242 |
1243 |
1244 |
1245 |
1246 |
1247 |
1248 |
1249 |
1250 |
1251 |
1252 |
1253 |
1254 |
1255 |
1256 |
1257 |
1258 |
1259 |
1260 |
1261 |
1262 |
1263 |
1264 |
1265 |
1266 |
1267 |
1268 |
1269 |
1270 |
1271 |
1272 |
1273 |
1274 |
1275 |
1276 |
1277 |
1278 |
1279 |
1280 |
1281 |
1282 |
1283 |
1284 |
1285 |
1286 |
1287 |
1288 |
1289 |
1290 |
1291 |
1292 |
1293 |
1294 |
1295 |
1296 |
1297 |
1298 |
1299 |
1300 |
1301 |
1302 |
1303 |
1304 |
1305 |
1306 |
1307 |
1308 |
1309 |
1310 |
1311 |
1312 |
1313 |
1314 |
1315 |
1316 |
1317 |
1318 |
1319 |
1320 |
1321 |
1322 |
1323 |
1324 |
1325 |
1326 |
1327 |
1328 |
1329 |
1330 |
1331 |
1332 |
1333 |
1334 |
1335 |
1336 |
1337 |
1338 |
1339 |
1340 |
1341 |
1342 |
1343 |
1344 |
1345 |
1346 |
1347 |
1348 |
1349 |
1350 |
1351 |
1352 |
1353 | BookStore:war exploded
1354 |
1355 |
1356 |
1357 |
1358 |
1359 |
1360 |
1361 |
1362 |
1363 |
1364 |
1365 |
1366 | Web
1367 |
1368 |
1369 |
1370 |
1371 |
1372 |
1373 |
1374 |
1375 |
1376 |
1377 |
1378 |
1379 |
1380 |
1381 |
1382 |
1383 |
1384 |
1385 |
1386 |
1387 |
1388 |
1389 | 1.8
1390 |
1391 |
1392 |
1393 |
1394 |
1395 |
1396 |
1397 |
1398 |
1399 |
1400 |
1401 | BookStore
1402 |
1403 |
1404 |
1405 |
1406 |
1407 |
1408 |
1409 |
1410 |
1411 |
1412 |
1413 |
1414 |
1415 |
1416 |
1417 |
1418 |
1419 |
1420 |
1421 |
1422 |
1423 |
1424 |
--------------------------------------------------------------------------------
/BookStore.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # BookStore
2 |
3 | servlet + jsp + mysql + jdbc 网上书店系统
4 |
5 | 
6 |
7 |
8 |
9 | 
10 |
11 |
12 |
13 | 
14 |
15 |
16 |
17 | 
18 |
19 |
20 |
21 | 
22 |
23 |
24 |
25 | 
26 |
27 |
28 |
29 | 
30 |
31 |
--------------------------------------------------------------------------------
/SQL/Product.sql:
--------------------------------------------------------------------------------
1 | CREATE database bookstore;
2 |
3 | use bookstore;
4 |
5 | CREATE TABLE `product` (
6 | `book_id` int(11) NOT NULL AUTO_INCREMENT,
7 | `book_name` varchar(100) NOT NULL,
8 | `book_price` double NOT NULL,
9 | PRIMARY KEY (`book_id`)
10 | ) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8
11 |
12 | INSERT INTO product (book_id,book_name,book_price)
13 | VALUES
14 | ('1', 'JAVA编程思想', '89.1'),
15 | ('2', 'Java核心技术一', '71.3'),
16 | ('3', '算法(第四版)', '82.9'),
17 | ('4', 'Head First Java', '68.7'),
18 | ('5', '计算机网络自顶向下方法', '65.2'),
19 | ('6', 'MySQL必知必会', '29.8'),
20 | ('7', '深入理解Java虚拟机', '65.2'),
21 | ('8', 'Java并发编程的艺术', '48.4'),
22 | ('9', '深入理解计算机系统', '114.7'),
23 | ('10', '编码:隐匿在计算机软硬件背后的语言', '56.1'),
24 | ('11', '计算机操作系统', '31.7'),
25 | ('12', 'Wireshark数据包分析实战', '41'),
26 | ('13', '图解TCP/IP', '46.3'),
27 | ('14', '图解HTTP', '38.7'),
28 | ('15', 'Head First Servlets and JSP', '88.5'),
29 | ('16', '大话数据结构', '50.2'),
30 | ('17', 'SQL必知必会', '24.7'),
31 | ('18', 'Head First设计模式', '83.3'),
32 | ('19', 'Java核心技术系列', '56.9'),
33 | ('20', '啊哈 算法', '37.7'),
34 | ('21', 'Java并发编程实战', '56.9');
35 |
36 |
--------------------------------------------------------------------------------
/out/artifacts/BookStore_war_exploded/WEB-INF/classes/com/dao/DBUtil.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StarryZB/BookStore/17127745f5861754c244ee1d2b56adf6995cf300/out/artifacts/BookStore_war_exploded/WEB-INF/classes/com/dao/DBUtil.class
--------------------------------------------------------------------------------
/out/artifacts/BookStore_war_exploded/WEB-INF/classes/com/dao/ProductDao.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StarryZB/BookStore/17127745f5861754c244ee1d2b56adf6995cf300/out/artifacts/BookStore_war_exploded/WEB-INF/classes/com/dao/ProductDao.class
--------------------------------------------------------------------------------
/out/artifacts/BookStore_war_exploded/WEB-INF/classes/com/entity/Product.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StarryZB/BookStore/17127745f5861754c244ee1d2b56adf6995cf300/out/artifacts/BookStore_war_exploded/WEB-INF/classes/com/entity/Product.class
--------------------------------------------------------------------------------
/out/artifacts/BookStore_war_exploded/WEB-INF/classes/com/entity/User.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StarryZB/BookStore/17127745f5861754c244ee1d2b56adf6995cf300/out/artifacts/BookStore_war_exploded/WEB-INF/classes/com/entity/User.class
--------------------------------------------------------------------------------
/out/artifacts/BookStore_war_exploded/WEB-INF/classes/com/filter/EncodingFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StarryZB/BookStore/17127745f5861754c244ee1d2b56adf6995cf300/out/artifacts/BookStore_war_exploded/WEB-INF/classes/com/filter/EncodingFilter.class
--------------------------------------------------------------------------------
/out/artifacts/BookStore_war_exploded/WEB-INF/classes/com/service/ProductService.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StarryZB/BookStore/17127745f5861754c244ee1d2b56adf6995cf300/out/artifacts/BookStore_war_exploded/WEB-INF/classes/com/service/ProductService.class
--------------------------------------------------------------------------------
/out/artifacts/BookStore_war_exploded/WEB-INF/classes/com/servlet/AddServlet.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StarryZB/BookStore/17127745f5861754c244ee1d2b56adf6995cf300/out/artifacts/BookStore_war_exploded/WEB-INF/classes/com/servlet/AddServlet.class
--------------------------------------------------------------------------------
/out/artifacts/BookStore_war_exploded/WEB-INF/classes/com/servlet/BuyServlet.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StarryZB/BookStore/17127745f5861754c244ee1d2b56adf6995cf300/out/artifacts/BookStore_war_exploded/WEB-INF/classes/com/servlet/BuyServlet.class
--------------------------------------------------------------------------------
/out/artifacts/BookStore_war_exploded/WEB-INF/classes/com/servlet/CheckOutServlet.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StarryZB/BookStore/17127745f5861754c244ee1d2b56adf6995cf300/out/artifacts/BookStore_war_exploded/WEB-INF/classes/com/servlet/CheckOutServlet.class
--------------------------------------------------------------------------------
/out/artifacts/BookStore_war_exploded/WEB-INF/classes/com/servlet/DeleteServlet.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StarryZB/BookStore/17127745f5861754c244ee1d2b56adf6995cf300/out/artifacts/BookStore_war_exploded/WEB-INF/classes/com/servlet/DeleteServlet.class
--------------------------------------------------------------------------------
/out/artifacts/BookStore_war_exploded/WEB-INF/classes/com/servlet/LoginServlet.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StarryZB/BookStore/17127745f5861754c244ee1d2b56adf6995cf300/out/artifacts/BookStore_war_exploded/WEB-INF/classes/com/servlet/LoginServlet.class
--------------------------------------------------------------------------------
/out/artifacts/BookStore_war_exploded/WEB-INF/classes/com/servlet/PageServlet.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StarryZB/BookStore/17127745f5861754c244ee1d2b56adf6995cf300/out/artifacts/BookStore_war_exploded/WEB-INF/classes/com/servlet/PageServlet.class
--------------------------------------------------------------------------------
/out/artifacts/BookStore_war_exploded/WEB-INF/lib/mysql-connector-java-5.1.40-bin.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StarryZB/BookStore/17127745f5861754c244ee1d2b56adf6995cf300/out/artifacts/BookStore_war_exploded/WEB-INF/lib/mysql-connector-java-5.1.40-bin.jar
--------------------------------------------------------------------------------
/out/artifacts/BookStore_war_exploded/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 | Login
9 | com.servlet.LoginServlet
10 |
11 |
12 |
13 | Login
14 | /login.action
15 |
16 |
17 |
18 | Buy
19 | com.servlet.BuyServlet
20 |
21 |
22 |
23 | Buy
24 | /buy.action
25 |
26 |
27 |
28 | Delete
29 | com.servlet.DeleteServlet
30 |
31 |
32 |
33 | Delete
34 | /delete.action
35 |
36 |
37 |
38 | Add
39 | com.servlet.AddServlet
40 |
41 |
42 |
43 | Add
44 | /add.action
45 |
46 |
47 |
48 | Back
49 | com.servlet.LoginServlet
50 |
51 |
52 |
53 | Back
54 | /back.action
55 |
56 |
57 |
58 | CheckOut
59 | com.servlet.CheckOutServlet
60 |
61 |
62 |
63 | CheckOut
64 | /checkout.action
65 |
66 |
67 |
68 | Page
69 | com.servlet.PageServlet
70 |
71 |
72 |
73 | Page
74 | /page.action
75 |
76 |
77 |
78 | Serach
79 | com.servlet.LoginServlet
80 |
81 |
82 |
83 | Serach
84 | /serach.action
85 |
86 |
87 |
88 | EncodingFilter
89 | com.filter.EncodingFilter
90 |
91 |
92 |
93 | EncodingFilter
94 | /*
95 |
96 |
--------------------------------------------------------------------------------
/out/artifacts/BookStore_war_exploded/cart.jsp:
--------------------------------------------------------------------------------
1 | <%@ page import="java.util.Map" %>
2 | <%@ page import="com.entity.Product" %>
3 | <%@ page import="java.text.DecimalFormat" %><%--
4 | Created by IntelliJ IDEA.
5 | User: StarryZB
6 | Date: 2017/11/4
7 | Time: 18:30
8 | To change this template use File | Settings | File Templates.
9 | --%>
10 | <%@ page contentType="text/html;charset=UTF-8" language="java" %>
11 |
12 |
13 |
14 |
15 |
16 |
17 | 购物清单
18 |
19 |
20 | <%
21 | Map idproductmap = (Map) session.getAttribute("idproductmap");
22 | Map idnummap = (Map) session.getAttribute("idnummap");
23 | %>
24 |
25 |
26 | 购物车
27 |
28 |
29 |
30 |
31 |
32 | 商品 |
33 | 商品名称 |
34 | 价格 |
35 | |
36 | 数目 |
37 | |
38 |
39 |
40 | <%
41 | double sum = 0;
42 | for (String key : idproductmap.keySet()) {
43 | Product product = idproductmap.get(key);
44 | int book_num = idnummap.get(key);
45 | sum += product.getBook_price() * book_num;
46 | DecimalFormat df = new DecimalFormat("#.00");
47 | sum = Double.parseDouble(df.format(sum));
48 | %>
49 |
50 |  |
51 | <%=product.getBook_name()%> |
52 | <%=product.getBook_price()%> |
53 |
54 |
58 | |
59 | <%=book_num%> |
60 |
61 |
65 | |
66 |
67 | <%
68 | }
69 | %>
70 |
71 |
72 |
73 |
74 |
75 |
78 |
79 |
80 | 合计: <%=sum%>
81 |
84 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/out/artifacts/BookStore_war_exploded/checkout.jsp:
--------------------------------------------------------------------------------
1 | <%--
2 | Created by IntelliJ IDEA.
3 | User: StarryZB
4 | Date: 2017/11/11
5 | Time: 22:50
6 | To change this template use File | Settings | File Templates.
7 | --%>
8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %>
9 |
10 |
11 | 结算
12 |
13 |
14 |
15 |
扫一扫
16 |
17 |

18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/out/artifacts/BookStore_war_exploded/image/book.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StarryZB/BookStore/17127745f5861754c244ee1d2b56adf6995cf300/out/artifacts/BookStore_war_exploded/image/book.png
--------------------------------------------------------------------------------
/out/artifacts/BookStore_war_exploded/image/checkout.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StarryZB/BookStore/17127745f5861754c244ee1d2b56adf6995cf300/out/artifacts/BookStore_war_exploded/image/checkout.png
--------------------------------------------------------------------------------
/out/artifacts/BookStore_war_exploded/index.jsp:
--------------------------------------------------------------------------------
1 | <%@ page import="com.servlet.LoginServlet" %><%--
2 | Created by IntelliJ IDEA.
3 | User: StarryZB
4 | Date: 2017/11/3
5 | Time: 17:19
6 | To change this template use File | Settings | File Templates.
7 | --%>
8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %>
9 |
10 |
11 |
12 |
13 |
14 | 登录页面
15 |
36 |
37 |
38 | <%
39 | if (session.getAttribute("user") != null) {
40 | %>
41 |
42 | <%
43 | }
44 | %>
45 |
46 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/out/artifacts/BookStore_war_exploded/product.jsp:
--------------------------------------------------------------------------------
1 | <%@ page import="java.util.List" %>
2 | <%@ page import="com.entity.Product" %>
3 | <%@ page import="java.util.Iterator" %>
4 | <%@ page import="java.util.ArrayList" %>
5 | <%@ page import="com.entity.User" %><%--
6 | Created by IntelliJ IDEA.
7 | User: StarryZB
8 | Date: 2017/11/3
9 | Time: 20:04
10 | To change this template use File | Settings | File Templates.
11 | --%>
12 | <%@ page contentType="text/html;charset=UTF-8" language="java" %>
13 |
14 |
15 |
16 |
17 |
18 | 商品信息
19 |
20 |
21 | <%
22 | User user = (User) session.getAttribute("user");
23 | %>
24 |
25 | 欢迎用户:<%=user.getName()%>
26 |
27 |
28 |
43 |
44 |
45 |
46 |
47 | 商品 |
48 | 商品名称 |
49 | 价格 | '
50 | 买买买 |
51 |
52 |
53 | <%
54 | List productList = (List) request.getAttribute("listproduct");
55 | Iterator iterator = productList.iterator();
56 | while (iterator.hasNext()) {
57 | Product product = iterator.next();
58 | %>
59 |
60 |  |
61 | <%=product.getBook_name()%> |
62 | <%=product.getBook_price()%> |
63 |
64 |
68 | |
69 |
70 | <%
71 | }
72 | %>
73 |
74 |
75 |
76 |
77 | <%
78 | int lastbegin = (int) request.getAttribute("begin") - 7;
79 | int nextbegin = (int) request.getAttribute("begin") + 7;
80 | int lastpagenum = lastbegin / 7;
81 | int nextpagenum = nextbegin / 7;
82 | %>
83 |
84 |
85 |
88 |
89 |
90 |
91 | <%
92 | if (lastpagenum < 0) {
93 | %>
94 |
95 |
98 |
99 | <%
100 | } else {
101 | %>
102 |
103 |
108 |
109 | <%
110 | }
111 | %>
112 | <%
113 | if (nextpagenum > 2) {
114 | %>
115 |
116 |
119 |
120 | <%
121 | } else {
122 | %>
123 |
124 |
129 |
130 | <%
131 | }
132 | %>
133 |
134 |
135 |
136 |
137 |
--------------------------------------------------------------------------------
/src/com/dao/DBUtil.java:
--------------------------------------------------------------------------------
1 | package com.dao;
2 |
3 | import java.sql.*;
4 |
5 | /**
6 | * Created by StarryZB on 2017/11/3.
7 | * 数据库工具类
8 | */
9 | public class DBUtil {
10 | private static final String driver = "com.mysql.jdbc.Driver"; //数据库驱动
11 | private static final String url="jdbc:mysql://localhost:3306/bookstore";//连接数据库的URL地址
12 | private static final String username="root";//数据库的用户名
13 | private static final String password="123456";//数据库的密码
14 |
15 |
16 | public static Connection getConn() {
17 | Connection conn = null;
18 | try {
19 | Class.forName(driver);
20 | } catch (ClassNotFoundException e) {
21 | e.printStackTrace();
22 | System.out.println("找不到驱动类");
23 | }
24 | try {
25 | conn = DriverManager.getConnection(url,username,password);
26 | } catch (SQLException e) {
27 | e.printStackTrace();
28 | System.out.println("连接失败");
29 | }
30 | return conn;
31 | }
32 | public static Statement createStmt(Connection conn) {
33 | Statement stmt = null;
34 | try {
35 | stmt = conn.createStatement();
36 | } catch (SQLException e) {
37 | e.printStackTrace();
38 | }
39 | return stmt;
40 | }
41 | public static ResultSet executeQuery(Statement stmt, String sql) {
42 | ResultSet rs = null;
43 | try {
44 | rs = stmt.executeQuery(sql);
45 | } catch (SQLException e) {
46 | e.printStackTrace();
47 | }
48 | return rs;
49 | }
50 | public static void closers(ResultSet rs) {
51 | if (rs != null) {
52 | try {
53 | rs.close();
54 | } catch (SQLException e) {
55 | e.printStackTrace();
56 | }
57 | }
58 | }
59 | public static void closestmt(Statement stmt) {
60 | if (stmt != null) {
61 | try {
62 | stmt.close();
63 | } catch (SQLException e) {
64 | e.printStackTrace();
65 | }
66 | }
67 | }
68 | public static void closeconn(Connection conn) {
69 | if (conn != null) {
70 | try {
71 | conn.close();
72 | } catch (SQLException e) {
73 | e.printStackTrace();
74 | }
75 | }
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/src/com/dao/ProductDao.java:
--------------------------------------------------------------------------------
1 | package com.dao;
2 |
3 | import com.entity.Product;
4 |
5 | import java.sql.*;
6 | import java.util.ArrayList;
7 | import java.util.List;
8 |
9 | /**
10 | * Created by StarryZB on 2017/11/3.
11 | * 数据库封装
12 | */
13 | public class ProductDao {
14 |
15 | public List getListProduct(int begin, int rows) {
16 | List productList = new ArrayList();
17 | String sql = "SELECT * FROM product LIMIT " + begin + " , " + rows;
18 | Connection connection = DBUtil.getConn();
19 | Statement statement = DBUtil.createStmt(connection);
20 | ResultSet resultSet = DBUtil.executeQuery(statement,sql);
21 | try {
22 | while (resultSet.next()) {
23 | Product product = new Product();
24 | product.setBook_id(resultSet.getInt("book_id"));
25 | product.setBook_name(resultSet.getString("book_name"));
26 | product.setBook_price(resultSet.getDouble("book_price"));
27 | productList.add(product);
28 | }
29 | } catch (SQLException e) {
30 | e.printStackTrace();
31 | } finally {
32 | DBUtil.closers(resultSet);
33 | DBUtil.closestmt(statement);
34 | DBUtil.closeconn(connection);
35 | }
36 | return productList;
37 | }
38 |
39 | public Product getProductById(String book_id) {
40 | String sql = "SELECT * FROM product WHERE book_id = " + book_id;
41 | Connection connection = DBUtil.getConn();
42 | Statement statement = DBUtil.createStmt(connection);
43 | ResultSet resultSet = DBUtil.executeQuery(statement,sql);
44 | Product product = new Product();
45 | try {
46 | while (resultSet.next()) {
47 | product.setBook_name(resultSet.getString("book_name"));
48 | product.setBook_price(resultSet.getDouble("book_price"));
49 | }
50 | } catch (SQLException e) {
51 | e.printStackTrace();
52 | } finally {
53 | DBUtil.closers(resultSet);
54 | DBUtil.closestmt(statement);
55 | DBUtil.closeconn(connection);
56 | }
57 | return product;
58 | }
59 |
60 | public List getProductByName(String book_name) {
61 | String sql = "SELECT * FROM product WHERE book_name Like '" + "%" + book_name + "%" + "'" ;
62 | Connection connection = DBUtil.getConn();
63 | Statement statement = DBUtil.createStmt(connection);
64 | ResultSet resultSet = DBUtil.executeQuery(statement,sql);
65 | List productList = new ArrayList();
66 | try {
67 | while (resultSet.next()) {
68 | Product product = new Product();
69 | product.setBook_id(resultSet.getInt("book_id"));
70 | product.setBook_name(resultSet.getString("book_name"));
71 | product.setBook_price(resultSet.getDouble("book_price"));
72 | productList.add(product);
73 | }
74 | } catch (SQLException e) {
75 | e.printStackTrace();
76 | } finally {
77 | DBUtil.closers(resultSet);
78 | DBUtil.closestmt(statement);
79 | DBUtil.closeconn(connection);
80 | }
81 | return productList;
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/src/com/entity/Product.java:
--------------------------------------------------------------------------------
1 | package com.entity;
2 |
3 | /**
4 | * Created by StarryZB on 2017/11/3.
5 | * 商品实体类
6 | */
7 | public class Product {
8 | public int book_id;
9 | public String book_name;
10 | public double book_price;
11 |
12 | public int getBook_id() {
13 | return book_id;
14 | }
15 |
16 | public void setBook_id(int book_id) {
17 | this.book_id = book_id;
18 | }
19 |
20 | public String getBook_name() {
21 | return book_name;
22 | }
23 |
24 | public void setBook_name(String book_name) {
25 | this.book_name = book_name;
26 | }
27 |
28 | public double getBook_price() {
29 | return book_price;
30 | }
31 |
32 | public void setBook_price(double book_price) {
33 | this.book_price = book_price;
34 | }
35 |
36 | @Override
37 | public String toString() {
38 | return "Product{" +
39 | "book_id=" + book_id +
40 | ", book_name='" + book_name + '\'' +
41 | ", book_price=" + book_price +
42 | '}';
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/com/entity/User.java:
--------------------------------------------------------------------------------
1 | package com.entity;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * Created by StarryZB on 2017/11/4.
7 | * 用户实体类
8 | */
9 | public class User {
10 | public String name;
11 | public String psssword;
12 | public List productList;
13 |
14 | public String getName() {
15 | return name;
16 | }
17 |
18 | public void setName(String name) {
19 | this.name = name;
20 | }
21 |
22 | public String getPsssword() {
23 | return psssword;
24 | }
25 |
26 | public void setPsssword(String psssword) {
27 | this.psssword = psssword;
28 | }
29 |
30 | public List getProductList() {
31 | return productList;
32 | }
33 |
34 | public void setProductList(List productList) {
35 | this.productList = productList;
36 | }
37 |
38 | @Override
39 | public String toString() {
40 | return "User{" +
41 | "name='" + name + '\'' +
42 | ", psssword='" + psssword + '\'' +
43 | ", productList=" + productList +
44 | '}';
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/com/filter/EncodingFilter.java:
--------------------------------------------------------------------------------
1 | package com.filter;
2 |
3 | import javax.servlet.*;
4 | import javax.servlet.http.HttpServletRequest;
5 | import javax.servlet.http.HttpServletResponse;
6 | import java.io.IOException;
7 |
8 | /**
9 | * Created by StarryZB on 2017/11/12.
10 | * 字符编码过滤器
11 | */
12 | public class EncodingFilter implements Filter {
13 | @Override
14 | public void init(FilterConfig filterConfig) throws ServletException {
15 |
16 | }
17 |
18 | @Override
19 | public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
20 | HttpServletRequest request = (HttpServletRequest) servletRequest;
21 | HttpServletResponse response = (HttpServletResponse) servletResponse;
22 | request.setCharacterEncoding("UTF-8");
23 | filterChain.doFilter(request, response);
24 | }
25 |
26 | @Override
27 | public void destroy() {
28 |
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/com/service/ProductService.java:
--------------------------------------------------------------------------------
1 | package com.service;
2 |
3 | import com.dao.ProductDao;
4 | import com.entity.Product;
5 |
6 | import java.util.List;
7 |
8 | /**
9 | * Created by StarryZB on 2018/2/3.
10 | * 商品相关业务功能
11 | */
12 | public class ProductService {
13 | public List getListProduct(int begin, int rows) {
14 | ProductDao productDao = new ProductDao();
15 | return productDao.getListProduct(begin,rows);
16 | }
17 |
18 | public Product getProductById(String book_id) {
19 | ProductDao productDao = new ProductDao();
20 | return productDao.getProductById(book_id);
21 | }
22 |
23 | public List getProductByName(String book_name) {
24 | ProductDao productDao = new ProductDao();
25 | return productDao.getProductByName(book_name);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/com/servlet/AddServlet.java:
--------------------------------------------------------------------------------
1 | package com.servlet;
2 |
3 | import com.entity.Product;
4 |
5 | import javax.servlet.ServletException;
6 | import javax.servlet.http.HttpServlet;
7 | import javax.servlet.http.HttpServletRequest;
8 | import javax.servlet.http.HttpServletResponse;
9 | import javax.servlet.http.HttpSession;
10 | import java.io.IOException;
11 | import java.util.Map;
12 |
13 | /**
14 | * Created by StarryZB on 2017/11/11.
15 | * 添加商品
16 | */
17 | public class AddServlet extends HttpServlet {
18 | @Override
19 | protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
20 | HttpSession session = req.getSession();
21 | Map idproductmap = (Map) session.getAttribute("idproductmap");
22 | Map idnummap = (Map) session.getAttribute("idnummap");
23 | String book_id = req.getParameter("add");
24 | int book_num = idnummap.get(book_id);
25 | book_num = book_num + 1;
26 | idnummap.put(book_id,book_num);
27 | session.setAttribute("idnummap",idnummap);
28 | req.getRequestDispatcher("cart.jsp").forward(req,resp);
29 | }
30 |
31 | @Override
32 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
33 | this.doPost(req,resp);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/com/servlet/BuyServlet.java:
--------------------------------------------------------------------------------
1 | package com.servlet;
2 |
3 | import com.entity.Product;
4 | import com.service.ProductService;
5 |
6 | import javax.servlet.ServletException;
7 | import javax.servlet.http.HttpServlet;
8 | import javax.servlet.http.HttpServletRequest;
9 | import javax.servlet.http.HttpServletResponse;
10 | import javax.servlet.http.HttpSession;
11 | import java.io.IOException;
12 | import java.util.HashMap;
13 | import java.util.Map;
14 |
15 | /**
16 | * Created by StarryZB on 2017/11/4.
17 | * 购物车页面初始化
18 | */
19 | public class BuyServlet extends HttpServlet {
20 | @Override
21 | protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
22 | HttpSession session = req.getSession();
23 | String book_id = req.getParameter("book_id");
24 | ProductService productService = new ProductService();
25 | Product product = productService.getProductById(book_id);//用book_id,通过id取得实体类
26 | product.setBook_id(Integer.parseInt(book_id));
27 | if (session.getAttribute("idproductmap") != null) {
28 | Map idproductmap = (Map) session.getAttribute("idproductmap");
29 | Map idnummap = (Map) session.getAttribute("idnummap");
30 | if (idnummap.get(book_id) != null) {
31 | int book_num = idnummap.get(book_id) + 1;
32 | idproductmap.put(book_id,product);
33 | idnummap.put(book_id,book_num);
34 | session.setAttribute("idproductmap",idproductmap);
35 | session.setAttribute("idnummap",idnummap);
36 | } else {
37 | int book_num = 1;//暂时定为1
38 | idproductmap.put(book_id,product);//键为id,值为实体类
39 | idnummap.put(book_id,book_num);//键为id,值为数目,可以改添加数量
40 | session.setAttribute("idproductmap",idproductmap);
41 | session.setAttribute("idnummap",idnummap);
42 | }
43 |
44 | } else {
45 | Map idproductmap = new HashMap();//id-product
46 | Map idnummap = new HashMap();//id-num
47 | int book_num = 1;//暂时定为1
48 | idproductmap.put(book_id,product);//键为id,值为实体类
49 | idnummap.put(book_id,book_num);//键为id,值为数目,可以改添加数量
50 | session.setAttribute("idproductmap",idproductmap);
51 | session.setAttribute("idnummap",idnummap);
52 | }
53 | req.getRequestDispatcher("cart.jsp").forward(req,resp);
54 |
55 | }
56 |
57 | @Override
58 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
59 | HttpSession session = req.getSession();
60 | if (session.getAttribute("idproductmap") == null) {
61 | Map idproductmap = new HashMap();
62 | Map idnummap = new HashMap();
63 | session.setAttribute("idproductmap",idproductmap);
64 | session.setAttribute("idnummap",idnummap);
65 | }
66 | req.getRequestDispatcher("cart.jsp").forward(req,resp);
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/com/servlet/CheckOutServlet.java:
--------------------------------------------------------------------------------
1 | package com.servlet;
2 |
3 | import javax.servlet.ServletException;
4 | import javax.servlet.http.HttpServlet;
5 | import javax.servlet.http.HttpServletRequest;
6 | import javax.servlet.http.HttpServletResponse;
7 | import java.io.IOException;
8 |
9 | /**
10 | * Created by StarryZB on 2017/11/11.
11 | * 结账页面初始化
12 | */
13 | public class CheckOutServlet extends HttpServlet {
14 | @Override
15 | protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
16 | resp.sendRedirect("checkout.jsp");
17 | }
18 |
19 | @Override
20 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
21 | this.doPost(req,resp);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/com/servlet/DeleteServlet.java:
--------------------------------------------------------------------------------
1 | package com.servlet;
2 |
3 | import com.entity.Product;
4 |
5 | import javax.servlet.ServletException;
6 | import javax.servlet.http.HttpServlet;
7 | import javax.servlet.http.HttpServletRequest;
8 | import javax.servlet.http.HttpServletResponse;
9 | import javax.servlet.http.HttpSession;
10 | import java.io.IOException;
11 | import java.util.Map;
12 |
13 | /**
14 | * Created by StarryZB on 2017/11/11.
15 | * 删除商品
16 | */
17 | public class DeleteServlet extends HttpServlet {
18 | @Override
19 | protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
20 | HttpSession session = req.getSession();
21 | Map idproductmap = (Map) session.getAttribute("idproductmap");
22 | Map idnummap = (Map) session.getAttribute("idnummap");
23 | String book_id = req.getParameter("delete");
24 | int book_num = idnummap.get(book_id);
25 | book_num = book_num - 1;
26 | if(book_num == 0) {
27 | idproductmap.remove(book_id);
28 | } else {
29 | idnummap.put(book_id,book_num);
30 | }
31 | session.setAttribute("idproductmap",idproductmap);
32 | session.setAttribute("idnummap",idnummap);
33 | req.getRequestDispatcher("cart.jsp").forward(req,resp);
34 |
35 | }
36 |
37 | @Override
38 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
39 | this.doPost(req,resp);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/com/servlet/LoginServlet.java:
--------------------------------------------------------------------------------
1 | package com.servlet;
2 |
3 | import com.entity.Product;
4 | import com.entity.User;
5 | import com.service.ProductService;
6 |
7 | import javax.servlet.ServletException;
8 | import javax.servlet.http.HttpServlet;
9 | import javax.servlet.http.HttpServletRequest;
10 | import javax.servlet.http.HttpServletResponse;
11 | import javax.servlet.http.HttpSession;
12 | import java.io.IOException;
13 | import java.util.List;
14 |
15 | /**
16 | * Created by StarryZB on 2017/11/3.
17 | * 商品展示页面初始化
18 | */
19 | public class LoginServlet extends HttpServlet {
20 | @Override
21 | protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
22 | HttpSession session = req.getSession();
23 | if (session.getAttribute("user") == null) {
24 | User user = new User();
25 | String name = req.getParameter("name");
26 | String password = req.getParameter("password");
27 | user.setName(name);
28 | user.setPsssword(password);
29 | session.setAttribute("user",user);
30 | }
31 | String bookname = req.getParameter("bookname");
32 | List listProduct;
33 | if (bookname != null && !"".equals(bookname)) {
34 | ProductService productService = new ProductService();
35 | listProduct = productService.getProductByName(bookname);
36 | } else {
37 | ProductService productService = new ProductService();
38 | listProduct = productService.getListProduct(0,7);
39 | }
40 | req.setAttribute("begin",0);
41 | req.setAttribute("listproduct",listProduct);
42 | req.getRequestDispatcher("product.jsp").forward(req,resp);
43 | }
44 |
45 | @Override
46 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
47 | this.doPost(req,resp);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/com/servlet/PageServlet.java:
--------------------------------------------------------------------------------
1 | package com.servlet;
2 |
3 | import com.entity.Product;
4 | import com.service.ProductService;
5 |
6 | import javax.servlet.ServletException;
7 | import javax.servlet.http.HttpServlet;
8 | import javax.servlet.http.HttpServletRequest;
9 | import javax.servlet.http.HttpServletResponse;
10 | import java.io.IOException;
11 | import java.util.List;
12 |
13 | /**
14 | * Created by StarryZB on 2017/11/12.
15 | * 商品翻页初始化
16 | */
17 | public class PageServlet extends HttpServlet {
18 | @Override
19 | protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
20 | this.doGet(req,resp);
21 | }
22 |
23 | @Override
24 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
25 | int page = Integer.parseInt(req.getParameter("page"));
26 | int begin = page * 7;
27 | ProductService productService = new ProductService();
28 | List listProduct = productService.getListProduct(begin,7);
29 | req.setAttribute("begin",begin);
30 | req.setAttribute("listproduct",listProduct);
31 | req.getRequestDispatcher("product.jsp").forward(req,resp);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/web/WEB-INF/classes/com/dao/DBUtil.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StarryZB/BookStore/17127745f5861754c244ee1d2b56adf6995cf300/web/WEB-INF/classes/com/dao/DBUtil.class
--------------------------------------------------------------------------------
/web/WEB-INF/classes/com/dao/ProductDao.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StarryZB/BookStore/17127745f5861754c244ee1d2b56adf6995cf300/web/WEB-INF/classes/com/dao/ProductDao.class
--------------------------------------------------------------------------------
/web/WEB-INF/classes/com/entity/Product.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StarryZB/BookStore/17127745f5861754c244ee1d2b56adf6995cf300/web/WEB-INF/classes/com/entity/Product.class
--------------------------------------------------------------------------------
/web/WEB-INF/classes/com/entity/User.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StarryZB/BookStore/17127745f5861754c244ee1d2b56adf6995cf300/web/WEB-INF/classes/com/entity/User.class
--------------------------------------------------------------------------------
/web/WEB-INF/classes/com/filter/EncodingFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StarryZB/BookStore/17127745f5861754c244ee1d2b56adf6995cf300/web/WEB-INF/classes/com/filter/EncodingFilter.class
--------------------------------------------------------------------------------
/web/WEB-INF/classes/com/service/ProductService.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StarryZB/BookStore/17127745f5861754c244ee1d2b56adf6995cf300/web/WEB-INF/classes/com/service/ProductService.class
--------------------------------------------------------------------------------
/web/WEB-INF/classes/com/servlet/AddServlet.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StarryZB/BookStore/17127745f5861754c244ee1d2b56adf6995cf300/web/WEB-INF/classes/com/servlet/AddServlet.class
--------------------------------------------------------------------------------
/web/WEB-INF/classes/com/servlet/BuyServlet.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StarryZB/BookStore/17127745f5861754c244ee1d2b56adf6995cf300/web/WEB-INF/classes/com/servlet/BuyServlet.class
--------------------------------------------------------------------------------
/web/WEB-INF/classes/com/servlet/CheckOutServlet.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StarryZB/BookStore/17127745f5861754c244ee1d2b56adf6995cf300/web/WEB-INF/classes/com/servlet/CheckOutServlet.class
--------------------------------------------------------------------------------
/web/WEB-INF/classes/com/servlet/DeleteServlet.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StarryZB/BookStore/17127745f5861754c244ee1d2b56adf6995cf300/web/WEB-INF/classes/com/servlet/DeleteServlet.class
--------------------------------------------------------------------------------
/web/WEB-INF/classes/com/servlet/LoginServlet.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StarryZB/BookStore/17127745f5861754c244ee1d2b56adf6995cf300/web/WEB-INF/classes/com/servlet/LoginServlet.class
--------------------------------------------------------------------------------
/web/WEB-INF/classes/com/servlet/PageServlet.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StarryZB/BookStore/17127745f5861754c244ee1d2b56adf6995cf300/web/WEB-INF/classes/com/servlet/PageServlet.class
--------------------------------------------------------------------------------
/web/WEB-INF/lib/mysql-connector-java-5.1.40-bin.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StarryZB/BookStore/17127745f5861754c244ee1d2b56adf6995cf300/web/WEB-INF/lib/mysql-connector-java-5.1.40-bin.jar
--------------------------------------------------------------------------------
/web/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 | Login
9 | com.servlet.LoginServlet
10 |
11 |
12 |
13 | Login
14 | /login.action
15 |
16 |
17 |
18 | Buy
19 | com.servlet.BuyServlet
20 |
21 |
22 |
23 | Buy
24 | /buy.action
25 |
26 |
27 |
28 | Delete
29 | com.servlet.DeleteServlet
30 |
31 |
32 |
33 | Delete
34 | /delete.action
35 |
36 |
37 |
38 | Add
39 | com.servlet.AddServlet
40 |
41 |
42 |
43 | Add
44 | /add.action
45 |
46 |
47 |
48 | Back
49 | com.servlet.LoginServlet
50 |
51 |
52 |
53 | Back
54 | /back.action
55 |
56 |
57 |
58 | CheckOut
59 | com.servlet.CheckOutServlet
60 |
61 |
62 |
63 | CheckOut
64 | /checkout.action
65 |
66 |
67 |
68 | Page
69 | com.servlet.PageServlet
70 |
71 |
72 |
73 | Page
74 | /page.action
75 |
76 |
77 |
78 | Serach
79 | com.servlet.LoginServlet
80 |
81 |
82 |
83 | Serach
84 | /serach.action
85 |
86 |
87 |
88 | EncodingFilter
89 | com.filter.EncodingFilter
90 |
91 |
92 |
93 | EncodingFilter
94 | /*
95 |
96 |
--------------------------------------------------------------------------------
/web/cart.jsp:
--------------------------------------------------------------------------------
1 | <%@ page import="java.util.Map" %>
2 | <%@ page import="com.entity.Product" %>
3 | <%@ page import="java.text.DecimalFormat" %><%--
4 | Created by IntelliJ IDEA.
5 | User: StarryZB
6 | Date: 2017/11/4
7 | Time: 18:30
8 | To change this template use File | Settings | File Templates.
9 | --%>
10 | <%@ page contentType="text/html;charset=UTF-8" language="java" %>
11 |
12 |
13 |
14 |
15 |
16 |
17 | 购物清单
18 |
19 |
20 | <%
21 | Map idproductmap = (Map) session.getAttribute("idproductmap");
22 | Map idnummap = (Map) session.getAttribute("idnummap");
23 | %>
24 |
25 |
26 | 购物车
27 |
28 |
29 |
30 |
31 |
32 | 商品 |
33 | 商品名称 |
34 | 价格 |
35 | |
36 | 数目 |
37 | |
38 |
39 |
40 | <%
41 | double sum = 0;
42 | for (String key : idproductmap.keySet()) {
43 | Product product = idproductmap.get(key);
44 | int book_num = idnummap.get(key);
45 | sum += product.getBook_price() * book_num;
46 | DecimalFormat df = new DecimalFormat("#.00");
47 | sum = Double.parseDouble(df.format(sum));
48 | %>
49 |
50 |  |
51 | <%=product.getBook_name()%> |
52 | <%=product.getBook_price()%> |
53 |
54 |
58 | |
59 | <%=book_num%> |
60 |
61 |
65 | |
66 |
67 | <%
68 | }
69 | %>
70 |
71 |
72 |
73 |
74 |
75 |
78 |
79 |
80 | 合计: <%=sum%>
81 |
84 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/web/checkout.jsp:
--------------------------------------------------------------------------------
1 | <%--
2 | Created by IntelliJ IDEA.
3 | User: StarryZB
4 | Date: 2017/11/11
5 | Time: 22:50
6 | To change this template use File | Settings | File Templates.
7 | --%>
8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %>
9 |
10 |
11 | 结算
12 |
13 |
14 |
15 |
扫一扫
16 |
17 |

18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/web/image/book.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StarryZB/BookStore/17127745f5861754c244ee1d2b56adf6995cf300/web/image/book.png
--------------------------------------------------------------------------------
/web/image/checkout.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StarryZB/BookStore/17127745f5861754c244ee1d2b56adf6995cf300/web/image/checkout.png
--------------------------------------------------------------------------------
/web/index.jsp:
--------------------------------------------------------------------------------
1 | <%@ page import="com.servlet.LoginServlet" %><%--
2 | Created by IntelliJ IDEA.
3 | User: StarryZB
4 | Date: 2017/11/3
5 | Time: 17:19
6 | To change this template use File | Settings | File Templates.
7 | --%>
8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %>
9 |
10 |
11 |
12 |
13 |
14 | 登录页面
15 |
36 |
37 |
38 | <%
39 | if (session.getAttribute("user") != null) {
40 | %>
41 |
42 | <%
43 | }
44 | %>
45 |
46 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/web/product.jsp:
--------------------------------------------------------------------------------
1 | <%@ page import="java.util.List" %>
2 | <%@ page import="com.entity.Product" %>
3 | <%@ page import="java.util.Iterator" %>
4 | <%@ page import="java.util.ArrayList" %>
5 | <%@ page import="com.entity.User" %><%--
6 | Created by IntelliJ IDEA.
7 | User: StarryZB
8 | Date: 2017/11/3
9 | Time: 20:04
10 | To change this template use File | Settings | File Templates.
11 | --%>
12 | <%@ page contentType="text/html;charset=UTF-8" language="java" %>
13 |
14 |
15 |
16 |
17 |
18 | 商品信息
19 |
20 |
21 | <%
22 | User user = (User) session.getAttribute("user");
23 | %>
24 |
25 | 欢迎用户:<%=user.getName()%>
26 |
27 |
28 |
43 |
44 |
45 |
46 |
47 | 商品 |
48 | 商品名称 |
49 | 价格 | '
50 | 买买买 |
51 |
52 |
53 | <%
54 | List productList = (List) request.getAttribute("listproduct");
55 | Iterator iterator = productList.iterator();
56 | while (iterator.hasNext()) {
57 | Product product = iterator.next();
58 | %>
59 |
60 |  |
61 | <%=product.getBook_name()%> |
62 | <%=product.getBook_price()%> |
63 |
64 |
68 | |
69 |
70 | <%
71 | }
72 | %>
73 |
74 |
75 |
76 |
77 | <%
78 | int lastbegin = (int) request.getAttribute("begin") - 7;
79 | int nextbegin = (int) request.getAttribute("begin") + 7;
80 | int lastpagenum = lastbegin / 7;
81 | int nextpagenum = nextbegin / 7;
82 | %>
83 |
84 |
85 |
88 |
89 |
90 |
91 | <%
92 | if (lastpagenum < 0) {
93 | %>
94 |
95 |
98 |
99 | <%
100 | } else {
101 | %>
102 |
103 |
108 |
109 | <%
110 | }
111 | %>
112 | <%
113 | if (nextpagenum > 2) {
114 | %>
115 |
116 |
119 |
120 | <%
121 | } else {
122 | %>
123 |
124 |
129 |
130 | <%
131 | }
132 | %>
133 |
134 |
135 |
136 |
137 |
--------------------------------------------------------------------------------