├── .settings ├── org.eclipse.wst.jsdt.ui.superType.name ├── org.eclipse.wst.jsdt.ui.superType.container ├── org.eclipse.core.resources.prefs ├── com.genuitec.eclipse.ws.prefs ├── com.genuitec.eclipse.core.prefs ├── org.eclipse.wst.common.project.facet.core.xml ├── org.eclipse.jdt.core.prefs ├── org.eclipse.wst.common.component └── .jsdtscope ├── WebRoot ├── META-INF │ └── MANIFEST.MF ├── images │ ├── 1.png │ ├── 2.png │ ├── 3.png │ ├── 4.png │ ├── 5.png │ ├── 6.png │ ├── nav.png │ ├── icon1.png │ ├── logo.png │ ├── rightw.gif │ ├── shuma1.jpg │ ├── shuma2.jpg │ ├── shuma3.jpg │ ├── shuma4.jpg │ └── shoppingabout.jpg ├── upload │ ├── 1.jpg │ ├── 2.jpg │ ├── 3.jpg │ ├── 4.jpg │ ├── 5.jpg │ ├── 6.jpg │ ├── 7.jpg │ ├── 8.jpg │ ├── 9.jpg │ ├── 10.jpg │ ├── 12.jpg │ ├── 13.jpg │ ├── 14.jpg │ ├── 15.jpg │ ├── 16.jpg │ ├── 17.jpg │ ├── 18.jpg │ ├── 19.jpg │ ├── 20.jpg │ ├── 21.jpg │ ├── 24.jpg │ ├── 25.jpg │ ├── 27.jpg │ ├── 28.jpg │ ├── 29.jpg │ ├── 30.jpg │ ├── 31.jpg │ ├── 32.jpg │ ├── 33.jpg │ ├── 34.jpg │ ├── 35.jpg │ ├── 36.jpg │ ├── 38.jpg │ ├── 39.jpg │ ├── 40.jpg │ ├── 41.jpg │ ├── 50.jpg │ ├── 51.jpg │ ├── 52.jpg │ ├── 53.jpg │ ├── 54.jpg │ ├── 55.jpg │ ├── 56.jpg │ ├── 60.jpg │ ├── 666.jpg │ ├── CSS.jpg │ ├── Linux.jpg │ ├── Python.jpg │ ├── Spring.jpg │ ├── bike01.jpg │ ├── bike04.jpg │ ├── bike05.jpg │ ├── bike10.jpg │ ├── ipod.jpg │ ├── kindle.jpg │ ├── sonymp3.jpg │ ├── Javascript.jpg │ ├── Photoshop_CS6.jpg │ └── kindle+touch.jpg ├── fonts │ ├── icomoon.eot │ ├── icomoon.ttf │ ├── icomoon.woff │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.ttf │ ├── glyphicons-halflings-regular.woff │ ├── glyphicons-halflings-regular.woff2 │ └── icomoon.svg ├── WEB-INF │ ├── lib │ │ ├── junit-4.10.jar │ │ ├── commons-io-2.2.jar │ │ ├── commons-fileupload-1.3.1.jar │ │ ├── taglibs-standard-impl-1.2.5.jar │ │ ├── taglibs-standard-spec-1.2.5.jar │ │ ├── mysql-connector-java-5.1.26-bin.jar │ │ ├── taglibs-standard-compat-1.2.5.jar │ │ └── taglibs-standard-jstlel-1.2.5.jar │ ├── classes │ │ ├── model │ │ │ ├── Cars.class │ │ │ ├── Items.class │ │ │ ├── Pager.class │ │ │ ├── Users.class │ │ │ └── buy_items.class │ │ ├── dao │ │ │ ├── CarsDao.class │ │ │ ├── ItemsDao.class │ │ │ ├── SortDao.class │ │ │ ├── UserDao.class │ │ │ ├── CarsDaoImpl.class │ │ │ ├── SortDaoImpl.class │ │ │ ├── UserDaoImpl.class │ │ │ └── ItemsDaoImpl.class │ │ ├── servlet │ │ │ ├── LogOut.class │ │ │ ├── BuyServlet.class │ │ │ ├── CarServlet.class │ │ │ ├── ImageServlet.class │ │ │ ├── LoginServlet.class │ │ │ ├── ShowCarServlet.class │ │ │ ├── addItemServlet.class │ │ │ ├── LimitItemsServlet.class │ │ │ ├── ShowItemServlet.class │ │ │ ├── SortItemsServlet.class │ │ │ ├── deleteCarServlet.class │ │ │ ├── registerServlet.class │ │ │ └── LimitByTypeServlet.class │ │ ├── test │ │ │ ├── CarsTest.class │ │ │ ├── ItemTest.class │ │ │ └── JdbcUtilTest.class │ │ ├── util │ │ │ ├── Constant.class │ │ │ ├── JdbcUtil.class │ │ │ └── StringUtil.class │ │ ├── filter │ │ │ └── LoginFilter.class │ │ ├── service │ │ │ ├── CarsService.class │ │ │ ├── ItemsService.class │ │ │ ├── SortService.class │ │ │ ├── UserService.class │ │ │ ├── CarsServiceImpl.class │ │ │ ├── ItemsServiceImpl.class │ │ │ ├── SortServiceImpl.class │ │ │ └── UserServiceImpl.class │ │ └── jdbc.properties │ ├── jsp │ │ ├── back │ │ │ └── back.jsp │ │ └── front │ │ │ ├── buy.jsp │ │ │ └── ShowCar.jsp │ └── web.xml ├── js │ ├── search.js │ ├── showImage.js │ ├── my.js │ └── time.js ├── fail.jsp ├── css │ ├── normalize.css │ ├── show.css │ ├── Login.css │ ├── search-form.css │ └── default.css ├── backresource │ ├── style1.css │ └── date.js ├── Login.jsp ├── load.jsp └── HomePage.jsp ├── README ├── src ├── jdbc.properties ├── service │ ├── UserService.java │ ├── SortService.java │ ├── CarsService.java │ ├── SortServiceImpl.java │ ├── UserServiceImpl.java │ ├── ItemsService.java │ ├── CarsServiceImpl.java │ └── ItemsServiceImpl.java ├── dao │ ├── UserDao.java │ ├── SortDao.java │ ├── CarsDao.java │ ├── ItemsDao.java │ ├── UserDaoImpl.java │ ├── SortDaoImpl.java │ ├── CarsDaoImpl.java │ └── ItemsDaoImpl.java ├── util │ ├── Constant.java │ ├── StringUtil.java │ └── JdbcUtil.java ├── test │ ├── CarsTest.java │ ├── JdbcUtilTest.java │ └── ItemTest.java ├── servlet │ ├── LogOut.java │ ├── ShowCarServlet.java │ ├── deleteCarServlet.java │ ├── ImageServlet.java │ ├── ShowItemServlet.java │ ├── LoginServlet.java │ ├── registerServlet.java │ ├── BuyServlet.java │ ├── LimitByTypeServlet.java │ ├── LimitItemsServlet.java │ ├── CarServlet.java │ ├── SortItemsServlet.java │ └── addItemServlet.java ├── model │ ├── buy_items.java │ ├── Cars.java │ ├── Users.java │ ├── Pager.java │ └── Items.java └── filter │ └── LoginFilter.java ├── .mymetadata ├── .classpath ├── .project └── shixun.sql /.settings/org.eclipse.wst.jsdt.ui.superType.name: -------------------------------------------------------------------------------- 1 | Window -------------------------------------------------------------------------------- /WebRoot/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Class-Path: 3 | 4 | -------------------------------------------------------------------------------- /WebRoot/images/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/images/1.png -------------------------------------------------------------------------------- /WebRoot/images/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/images/2.png -------------------------------------------------------------------------------- /WebRoot/images/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/images/3.png -------------------------------------------------------------------------------- /WebRoot/images/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/images/4.png -------------------------------------------------------------------------------- /WebRoot/images/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/images/5.png -------------------------------------------------------------------------------- /WebRoot/images/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/images/6.png -------------------------------------------------------------------------------- /WebRoot/upload/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/1.jpg -------------------------------------------------------------------------------- /WebRoot/upload/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/2.jpg -------------------------------------------------------------------------------- /WebRoot/upload/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/3.jpg -------------------------------------------------------------------------------- /WebRoot/upload/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/4.jpg -------------------------------------------------------------------------------- /WebRoot/upload/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/5.jpg -------------------------------------------------------------------------------- /WebRoot/upload/6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/6.jpg -------------------------------------------------------------------------------- /WebRoot/upload/7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/7.jpg -------------------------------------------------------------------------------- /WebRoot/upload/8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/8.jpg -------------------------------------------------------------------------------- /WebRoot/upload/9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/9.jpg -------------------------------------------------------------------------------- /WebRoot/images/nav.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/images/nav.png -------------------------------------------------------------------------------- /WebRoot/upload/10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/10.jpg -------------------------------------------------------------------------------- /WebRoot/upload/12.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/12.jpg -------------------------------------------------------------------------------- /WebRoot/upload/13.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/13.jpg -------------------------------------------------------------------------------- /WebRoot/upload/14.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/14.jpg -------------------------------------------------------------------------------- /WebRoot/upload/15.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/15.jpg -------------------------------------------------------------------------------- /WebRoot/upload/16.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/16.jpg -------------------------------------------------------------------------------- /WebRoot/upload/17.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/17.jpg -------------------------------------------------------------------------------- /WebRoot/upload/18.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/18.jpg -------------------------------------------------------------------------------- /WebRoot/upload/19.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/19.jpg -------------------------------------------------------------------------------- /WebRoot/upload/20.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/20.jpg -------------------------------------------------------------------------------- /WebRoot/upload/21.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/21.jpg -------------------------------------------------------------------------------- /WebRoot/upload/24.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/24.jpg -------------------------------------------------------------------------------- /WebRoot/upload/25.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/25.jpg -------------------------------------------------------------------------------- /WebRoot/upload/27.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/27.jpg -------------------------------------------------------------------------------- /WebRoot/upload/28.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/28.jpg -------------------------------------------------------------------------------- /WebRoot/upload/29.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/29.jpg -------------------------------------------------------------------------------- /WebRoot/upload/30.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/30.jpg -------------------------------------------------------------------------------- /WebRoot/upload/31.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/31.jpg -------------------------------------------------------------------------------- /WebRoot/upload/32.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/32.jpg -------------------------------------------------------------------------------- /WebRoot/upload/33.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/33.jpg -------------------------------------------------------------------------------- /WebRoot/upload/34.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/34.jpg -------------------------------------------------------------------------------- /WebRoot/upload/35.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/35.jpg -------------------------------------------------------------------------------- /WebRoot/upload/36.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/36.jpg -------------------------------------------------------------------------------- /WebRoot/upload/38.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/38.jpg -------------------------------------------------------------------------------- /WebRoot/upload/39.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/39.jpg -------------------------------------------------------------------------------- /WebRoot/upload/40.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/40.jpg -------------------------------------------------------------------------------- /WebRoot/upload/41.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/41.jpg -------------------------------------------------------------------------------- /WebRoot/upload/50.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/50.jpg -------------------------------------------------------------------------------- /WebRoot/upload/51.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/51.jpg -------------------------------------------------------------------------------- /WebRoot/upload/52.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/52.jpg -------------------------------------------------------------------------------- /WebRoot/upload/53.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/53.jpg -------------------------------------------------------------------------------- /WebRoot/upload/54.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/54.jpg -------------------------------------------------------------------------------- /WebRoot/upload/55.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/55.jpg -------------------------------------------------------------------------------- /WebRoot/upload/56.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/56.jpg -------------------------------------------------------------------------------- /WebRoot/upload/60.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/60.jpg -------------------------------------------------------------------------------- /WebRoot/upload/666.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/666.jpg -------------------------------------------------------------------------------- /WebRoot/upload/CSS.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/CSS.jpg -------------------------------------------------------------------------------- /.settings/org.eclipse.wst.jsdt.ui.superType.container: -------------------------------------------------------------------------------- 1 | org.eclipse.wst.jsdt.launching.baseBrowserLibrary -------------------------------------------------------------------------------- /WebRoot/fonts/icomoon.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/fonts/icomoon.eot -------------------------------------------------------------------------------- /WebRoot/fonts/icomoon.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/fonts/icomoon.ttf -------------------------------------------------------------------------------- /WebRoot/images/icon1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/images/icon1.png -------------------------------------------------------------------------------- /WebRoot/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/images/logo.png -------------------------------------------------------------------------------- /WebRoot/images/rightw.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/images/rightw.gif -------------------------------------------------------------------------------- /WebRoot/images/shuma1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/images/shuma1.jpg -------------------------------------------------------------------------------- /WebRoot/images/shuma2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/images/shuma2.jpg -------------------------------------------------------------------------------- /WebRoot/images/shuma3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/images/shuma3.jpg -------------------------------------------------------------------------------- /WebRoot/images/shuma4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/images/shuma4.jpg -------------------------------------------------------------------------------- /WebRoot/upload/Linux.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/Linux.jpg -------------------------------------------------------------------------------- /WebRoot/upload/Python.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/Python.jpg -------------------------------------------------------------------------------- /WebRoot/upload/Spring.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/Spring.jpg -------------------------------------------------------------------------------- /WebRoot/upload/bike01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/bike01.jpg -------------------------------------------------------------------------------- /WebRoot/upload/bike04.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/bike04.jpg -------------------------------------------------------------------------------- /WebRoot/upload/bike05.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/bike05.jpg -------------------------------------------------------------------------------- /WebRoot/upload/bike10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/bike10.jpg -------------------------------------------------------------------------------- /WebRoot/upload/ipod.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/ipod.jpg -------------------------------------------------------------------------------- /WebRoot/upload/kindle.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/kindle.jpg -------------------------------------------------------------------------------- /WebRoot/fonts/icomoon.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/fonts/icomoon.woff -------------------------------------------------------------------------------- /WebRoot/upload/sonymp3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/sonymp3.jpg -------------------------------------------------------------------------------- /WebRoot/upload/Javascript.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/Javascript.jpg -------------------------------------------------------------------------------- /.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//WebRoot/Login.jsp=UTF-8 3 | -------------------------------------------------------------------------------- /WebRoot/images/shoppingabout.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/images/shoppingabout.jpg -------------------------------------------------------------------------------- /WebRoot/upload/Photoshop_CS6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/Photoshop_CS6.jpg -------------------------------------------------------------------------------- /WebRoot/upload/kindle+touch.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/upload/kindle+touch.jpg -------------------------------------------------------------------------------- /.settings/com.genuitec.eclipse.ws.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | ws.framework.id=com.genuitec.eclipse.ws.jaxws 3 | -------------------------------------------------------------------------------- /WebRoot/WEB-INF/lib/junit-4.10.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/lib/junit-4.10.jar -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/model/Cars.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/model/Cars.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/lib/commons-io-2.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/lib/commons-io-2.2.jar -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/dao/CarsDao.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/dao/CarsDao.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/dao/ItemsDao.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/dao/ItemsDao.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/dao/SortDao.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/dao/SortDao.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/dao/UserDao.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/dao/UserDao.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/model/Items.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/model/Items.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/model/Pager.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/model/Pager.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/model/Users.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/model/Users.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/dao/CarsDaoImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/dao/CarsDaoImpl.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/dao/SortDaoImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/dao/SortDaoImpl.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/dao/UserDaoImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/dao/UserDaoImpl.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/model/buy_items.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/model/buy_items.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/servlet/LogOut.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/servlet/LogOut.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/test/CarsTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/test/CarsTest.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/test/ItemTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/test/ItemTest.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/util/Constant.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/util/Constant.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/util/JdbcUtil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/util/JdbcUtil.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/util/StringUtil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/util/StringUtil.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/dao/ItemsDaoImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/dao/ItemsDaoImpl.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/test/JdbcUtilTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/test/JdbcUtilTest.class -------------------------------------------------------------------------------- /WebRoot/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /WebRoot/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /WebRoot/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/filter/LoginFilter.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/filter/LoginFilter.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/service/CarsService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/service/CarsService.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/service/ItemsService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/service/ItemsService.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/service/SortService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/service/SortService.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/service/UserService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/service/UserService.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/servlet/BuyServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/servlet/BuyServlet.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/servlet/CarServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/servlet/CarServlet.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/servlet/ImageServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/servlet/ImageServlet.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/servlet/LoginServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/servlet/LoginServlet.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/lib/commons-fileupload-1.3.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/lib/commons-fileupload-1.3.1.jar -------------------------------------------------------------------------------- /WebRoot/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/servlet/ShowCarServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/servlet/ShowCarServlet.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/servlet/addItemServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/servlet/addItemServlet.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/lib/taglibs-standard-impl-1.2.5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/lib/taglibs-standard-impl-1.2.5.jar -------------------------------------------------------------------------------- /WebRoot/WEB-INF/lib/taglibs-standard-spec-1.2.5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/lib/taglibs-standard-spec-1.2.5.jar -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/service/CarsServiceImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/service/CarsServiceImpl.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/service/ItemsServiceImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/service/ItemsServiceImpl.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/service/SortServiceImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/service/SortServiceImpl.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/service/UserServiceImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/service/UserServiceImpl.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/servlet/LimitItemsServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/servlet/LimitItemsServlet.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/servlet/ShowItemServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/servlet/ShowItemServlet.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/servlet/SortItemsServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/servlet/SortItemsServlet.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/servlet/deleteCarServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/servlet/deleteCarServlet.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/servlet/registerServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/servlet/registerServlet.class -------------------------------------------------------------------------------- /WebRoot/WEB-INF/lib/mysql-connector-java-5.1.26-bin.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/lib/mysql-connector-java-5.1.26-bin.jar -------------------------------------------------------------------------------- /WebRoot/WEB-INF/lib/taglibs-standard-compat-1.2.5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/lib/taglibs-standard-compat-1.2.5.jar -------------------------------------------------------------------------------- /WebRoot/WEB-INF/lib/taglibs-standard-jstlel-1.2.5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/lib/taglibs-standard-jstlel-1.2.5.jar -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/servlet/LimitByTypeServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhouliang58/demo1/HEAD/WebRoot/WEB-INF/classes/servlet/LimitByTypeServlet.class -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | 购物网站,实现了登陆,注销,注册(含验证码); 2 | 实现了购物车,批量删除购物车与批量购买; 3 | 实现了用户发布商品,对商品按人气和价格排序,分页、分类查看商品; 4 | 实现了可隐藏的搜索框,首页图片滚动; 5 | Mysql数据库,junit测试工具,jstl标签库,文件上传用fileupload和io实现,mvc设计模式 -------------------------------------------------------------------------------- /src/jdbc.properties: -------------------------------------------------------------------------------- 1 | jdbc.username=admin 2 | jdbc.password=admin 3 | jdbc.driver=com.mysql.jdbc.Driver 4 | jdbc.url=jdbc\:mysql\://127.0.0.1/shixun?characterEncoding\=utf-8 5 | -------------------------------------------------------------------------------- /.settings/com.genuitec.eclipse.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | validator.Checked=WebRoot/Show.jsp,WebRoot/ShowSort.jsp,WebRoot/ShowType.jsp 3 | validator.Unchecked= 4 | -------------------------------------------------------------------------------- /WebRoot/WEB-INF/classes/jdbc.properties: -------------------------------------------------------------------------------- 1 | jdbc.username=admin 2 | jdbc.password=admin 3 | jdbc.driver=com.mysql.jdbc.Driver 4 | jdbc.url=jdbc\:mysql\://127.0.0.1/shixun?characterEncoding\=utf-8 5 | -------------------------------------------------------------------------------- /src/service/UserService.java: -------------------------------------------------------------------------------- 1 | package service; 2 | 3 | import model.Users; 4 | 5 | public interface UserService { 6 | //从数据库里面检验用户信息,登录检测 7 | public Users findAllUsers(Users user); 8 | 9 | //注册用户信息 10 | public boolean registerUser(Users registerUser); 11 | } 12 | -------------------------------------------------------------------------------- /src/dao/UserDao.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import java.util.List; 4 | 5 | import model.Users; 6 | 7 | public interface UserDao { 8 | //从数据库里面检验用户信息,登录检测 9 | public List findAllUsers(Users user); 10 | 11 | //注册用户信息 12 | public boolean registerUser(Users registerUser); 13 | } 14 | -------------------------------------------------------------------------------- /src/util/Constant.java: -------------------------------------------------------------------------------- 1 | package util; 2 | 3 | public class Constant { 4 | 5 | 6 | 7 | /** 8 | * 默认每页显示多少条记录 9 | */ 10 | public static final int DEFAULT_PAGE_SIZE = 8; 11 | 12 | /** 13 | * 默认显示第几页记录 14 | */ 15 | public static final int DEFAULT_PAGE_NUM = 1; 16 | 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.mymetadata: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/dao/SortDao.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import model.Items; 4 | import model.Pager; 5 | 6 | public interface SortDao { 7 | //根据价格对商品排序 8 | public Pager SortByPrice(Items searchModel, int pageNum, 9 | int pageSize); 10 | //根据人气对商品排序 11 | public Pager SortByHot(Items searchModel, int pageNum, 12 | int pageSize); 13 | } 14 | -------------------------------------------------------------------------------- /src/service/SortService.java: -------------------------------------------------------------------------------- 1 | package service; 2 | 3 | import model.Items; 4 | import model.Pager; 5 | 6 | public interface SortService { 7 | //根据价格对商品排序 8 | public Pager SortByPrice(Items searchModel, int pageNum, 9 | int pageSize); 10 | //根据人气对商品排序 11 | public Pager SortByHot(Items searchModel, int pageNum, 12 | int pageSize); 13 | } 14 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 4 | org.eclipse.jdt.core.compiler.compliance=1.6 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.source=1.6 8 | -------------------------------------------------------------------------------- /src/util/StringUtil.java: -------------------------------------------------------------------------------- 1 | package util; 2 | 3 | import java.util.regex.Matcher; 4 | import java.util.regex.Pattern; 5 | 6 | public class StringUtil { 7 | 8 | /** 9 | * 校验字符串是否是大于0的数字 10 | * @param string 11 | * @return 12 | */ 13 | public static boolean isNum(String string){ 14 | Pattern pattern = Pattern.compile("[1-9]{1}\\d*"); 15 | Matcher matcher = pattern.matcher(string); 16 | return matcher.matches(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /.settings/org.eclipse.wst.common.component: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.settings/.jsdtscope: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/service/CarsService.java: -------------------------------------------------------------------------------- 1 | package service; 2 | 3 | import java.util.List; 4 | 5 | import model.Items; 6 | 7 | public interface CarsService { 8 | //添加商品和用户信息到购物车中 9 | public boolean addItemToCar(int userID , Items item , int number); 10 | 11 | //根据用户ID,遍历购物车,返回所有的商品信息 12 | public List ShowItemInCar(int userID ); 13 | 14 | //为购物车中已经存在的商品增加数量 15 | public boolean updateItemInCar(int itemID,int userID,int number); 16 | 17 | //添加商品信息 18 | public boolean addItem(Items additem); 19 | 20 | //删除商品信息 21 | public boolean deleteItems(int userID , int id[]); 22 | } 23 | -------------------------------------------------------------------------------- /src/dao/CarsDao.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import java.util.List; 4 | 5 | import model.Items; 6 | 7 | public interface CarsDao { 8 | //添加商品和用户信息到购物车中(添加的商品必须是购物车中不存在的) 9 | public boolean addItemToCar(int userID , Items item , int number); 10 | 11 | //根据用户ID,遍历购物车,返回所有的商品信息 12 | public List ShowItemInCar(int userID ); 13 | 14 | //为购物车中已经存在的商品增加数量 15 | public boolean updateItemInCar(int itemID,int userID,int number); 16 | 17 | //添加商品信息 18 | public boolean addItem(Items additem); 19 | 20 | //删除商品信息 21 | public boolean deleteItems(int userID , int id[]); 22 | } 23 | -------------------------------------------------------------------------------- /src/service/SortServiceImpl.java: -------------------------------------------------------------------------------- 1 | package service; 2 | 3 | import dao.SortDao; 4 | import dao.SortDaoImpl; 5 | import model.Items; 6 | import model.Pager; 7 | 8 | public class SortServiceImpl implements SortService { 9 | private SortDao sortDao ; 10 | public SortServiceImpl(){ 11 | sortDao = new SortDaoImpl(); 12 | } 13 | @Override 14 | public Pager SortByPrice(Items searchModel, int pageNum, int pageSize) { 15 | Pager result = sortDao.SortByPrice(searchModel, pageNum, pageSize); 16 | return result; 17 | } 18 | 19 | @Override 20 | public Pager SortByHot(Items searchModel, int pageNum, int pageSize) { 21 | Pager result = sortDao.SortByHot(searchModel, pageNum, pageSize); 22 | return result; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/service/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package service; 2 | 3 | import java.util.List; 4 | 5 | import dao.UserDao; 6 | import dao.UserDaoImpl; 7 | import model.Users; 8 | 9 | public class UserServiceImpl implements UserService { 10 | private UserDao userDao; 11 | public UserServiceImpl(){ 12 | userDao = new UserDaoImpl(); 13 | } 14 | @Override 15 | public Users findAllUsers(Users user) { 16 | Users resultUser = new Users(); 17 | resultUser = null; 18 | List list = null; 19 | list = userDao.findAllUsers(user); 20 | if(list.size()>0){ 21 | resultUser = (Users) list.get(0); 22 | } 23 | return resultUser; 24 | } 25 | 26 | @Override 27 | public boolean registerUser(Users registerUser) { 28 | boolean flag = userDao.registerUser(registerUser); 29 | return flag; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/service/ItemsService.java: -------------------------------------------------------------------------------- 1 | package service; 2 | 3 | import java.util.List; 4 | 5 | import model.Items; 6 | import model.Pager; 7 | 8 | 9 | 10 | 11 | public interface ItemsService { 12 | 13 | /** 14 | * 根据查询条件,查询商品分页信息 15 | * @param searchModel 封装查询条件 16 | * @param pageNum 查询第几页数据 17 | * @param pageSize 每页显示多少条记录 18 | * @return 查询结果 19 | */ 20 | public Pager findItems(Items searchModel, int pageNum,int pageSize); 21 | /** 22 | * 根据商品类型分页 23 | */ 24 | public Pager typeItems(Items searchModel, int pageNum,int pageSize); 25 | //获取一个商品信息 26 | public List getOneItem(int id); 27 | //更新商品热度 28 | public boolean addItemHot(int id); 29 | //购买商品 30 | public boolean buyItem(int userID , Items buyItem , String buy_Time); 31 | 32 | //添加商品信息 33 | public boolean addItem(Items additem); 34 | } 35 | -------------------------------------------------------------------------------- /src/test/CarsTest.java: -------------------------------------------------------------------------------- 1 | package test; 2 | 3 | import model.Items; 4 | 5 | import org.junit.Test; 6 | 7 | import dao.CarsDaoImpl; 8 | 9 | public class CarsTest { 10 | @Test 11 | public void addToCar(){ 12 | CarsDaoImpl cars = new CarsDaoImpl(); 13 | Items item = new Items(); 14 | item.setContact("15243616117"); 15 | item.setDiscription("新的"); 16 | item.setId(33); 17 | item.setImage("3.jpg"); 18 | item.setName("电脑"); 19 | item.setPrice(500); 20 | cars.addItemToCar(33, item, 10); 21 | } 22 | @Test 23 | public void listCar(){ 24 | CarsDaoImpl cars = new CarsDaoImpl(); 25 | cars.ShowItemInCar(1); 26 | } 27 | 28 | @Test 29 | public void deleteCar(){ 30 | CarsDaoImpl cars = new CarsDaoImpl(); 31 | int[] id = {114}; 32 | int userID = 26; 33 | System.out.println(cars.deleteItems(userID, id)); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/dao/ItemsDao.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | 4 | import java.util.List; 5 | 6 | import model.Items; 7 | import model.Pager; 8 | 9 | public interface ItemsDao { 10 | /** 11 | * 根据查询条件,查询商品分页信息 12 | * @param searchModel 封装查询条件 13 | * @param pageNum 查询第几页数据 14 | * @param pageSize 每页显示多少条记录 15 | * @return 查询结果 16 | */ 17 | public Pager findItems(Items searchModel, int pageNum, 18 | int pageSize); 19 | /** 20 | * 根据商品类型分页 21 | */ 22 | public Pager typeItems(Items searchModel, int pageNum, 23 | int pageSize); 24 | 25 | //获取一个商品信息 26 | public List getOneItem(int id); 27 | 28 | //更新商品热度 29 | public boolean addItemHot(int id); 30 | 31 | //购买商品 32 | public boolean buyItem(int userID , Items buyItem , String buy_Time); 33 | 34 | //添加商品信息,发布商品 35 | public boolean addItem(Items additem); 36 | } 37 | -------------------------------------------------------------------------------- /src/servlet/LogOut.java: -------------------------------------------------------------------------------- 1 | package servlet; 2 | 3 | import java.io.IOException; 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 | 10 | public class LogOut extends HttpServlet { 11 | 12 | 13 | private static final long serialVersionUID = -499486930268676480L; 14 | 15 | 16 | public void doGet(HttpServletRequest request, HttpServletResponse response) 17 | throws ServletException, IOException { 18 | this.doPost(request, response); 19 | } 20 | 21 | 22 | public void doPost(HttpServletRequest request, HttpServletResponse response) 23 | throws ServletException, IOException { 24 | request.getSession().removeAttribute("loginUser"); 25 | response.sendRedirect(request.getContextPath()+"/Login.jsp"); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /WebRoot/WEB-INF/jsp/back/back.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 2 | <% 3 | String path = request.getContextPath(); 4 | String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 5 | %> 6 | 7 | 8 | 9 | 10 | 11 | 12 | My JSP 'back.jsp' starting page 13 | 14 | 15 | 16 | 17 | 18 | 19 | 22 | 23 | 24 | 25 | 26 | 这是后台页面!
27 | 28 | 29 | -------------------------------------------------------------------------------- /src/test/JdbcUtilTest.java: -------------------------------------------------------------------------------- 1 | package test; 2 | 3 | import java.sql.SQLException; 4 | import java.text.SimpleDateFormat; 5 | 6 | import java.util.Date; 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | import org.junit.Test; 11 | 12 | import util.JdbcUtil; 13 | 14 | public class JdbcUtilTest { 15 | @Test 16 | public void c3p0DataSourceTest() { 17 | JdbcUtil jdbcUtil = new JdbcUtil(); 18 | jdbcUtil.getConnection(); 19 | try { 20 | List> result = jdbcUtil.findResult( 21 | "select * from items", null); 22 | for (Map m : result) { 23 | System.out.println(m); 24 | } 25 | } catch (SQLException e) { 26 | e.printStackTrace(); 27 | } finally { 28 | jdbcUtil.releaseConn(); 29 | } 30 | } 31 | 32 | @Test 33 | public void DateTest() { 34 | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式 35 | System.out.println(df.format(new Date()));// new Date()为获取当前系统时间 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/service/CarsServiceImpl.java: -------------------------------------------------------------------------------- 1 | package service; 2 | 3 | import java.util.List; 4 | 5 | import dao.CarsDao; 6 | import dao.CarsDaoImpl; 7 | 8 | import model.Items; 9 | 10 | public class CarsServiceImpl implements CarsService { 11 | private CarsDao carsDao; 12 | public CarsServiceImpl(){ 13 | carsDao = new CarsDaoImpl(); 14 | } 15 | @Override 16 | public boolean addItemToCar(int userID, Items item, int number) { 17 | return carsDao.addItemToCar(userID, item, number); 18 | } 19 | 20 | @Override 21 | public List ShowItemInCar(int userID) { 22 | return carsDao.ShowItemInCar(userID); 23 | } 24 | @Override 25 | public boolean updateItemInCar(int itemID, int userID, int number) { 26 | return carsDao.updateItemInCar(itemID, userID, number); 27 | } 28 | @Override 29 | public boolean addItem(Items additem) { 30 | boolean flag = carsDao.addItem(additem); 31 | return flag; 32 | } 33 | @Override 34 | public boolean deleteItems(int userID, int[] id) { 35 | boolean flag = carsDao.deleteItems(userID, id); 36 | return flag; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /WebRoot/js/search.js: -------------------------------------------------------------------------------- 1 | function searchToggle(obj, evt){ 2 | var container = $(obj).closest('.search-wrapper'); 3 | 4 | if(!container.hasClass('active')){ 5 | container.addClass('active'); 6 | evt.preventDefault(); 7 | } 8 | else if(container.hasClass('active') && $(obj).closest('.input-holder').length == 0){ 9 | container.removeClass('active'); 10 | // clear input 11 | container.find('.search-input').val(''); 12 | // clear and hide result container when we press close 13 | container.find('.result-container').fadeOut(100, function(){$(this).empty();}); 14 | } 15 | } 16 | 17 | function submitFn(obj, evt){ 18 | value = $(obj).find('.search-input').val().trim(); 19 | 20 | _html = "Yup yup! Your search text sounds like this: "; 21 | 22 | if(!value.length){ 23 | 24 | } 25 | else{ 26 | //如果输入不为空 27 | window.location.href="servlet/LimitItemsServlet?itemName="+value+"#location"; 28 | } 29 | 30 | $(obj).find('.result-container').html('' + _html + ''); 31 | $(obj).find('.result-container').fadeIn(100); 32 | 33 | evt.preventDefault(); 34 | } -------------------------------------------------------------------------------- /WebRoot/fail.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 2 | <% 3 | String path = request.getContextPath(); 4 | String basePath = request.getScheme() + "://" 5 | + request.getServerName() + ":" + request.getServerPort() 6 | + path + "/"; 7 | %> 8 | 9 | 10 | 11 | 12 | 13 | 登陆失败 14 | 15 | 16 | 17 | 18 | 30 |
31 |

登录失败,请检查用户名和密码!

32 | 点击返回登陆页面 33 |
34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /src/servlet/ShowCarServlet.java: -------------------------------------------------------------------------------- 1 | package servlet; 2 | 3 | import java.io.IOException; 4 | import java.util.ArrayList; 5 | import java.util.List; 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 | 12 | import service.CarsService; 13 | import service.CarsServiceImpl; 14 | 15 | import model.Items; 16 | import model.Users; 17 | 18 | 19 | 20 | public class ShowCarServlet extends HttpServlet { 21 | 22 | 23 | private static final long serialVersionUID = -9079247542889575590L; 24 | private CarsService carService = new CarsServiceImpl(); 25 | 26 | public void doGet(HttpServletRequest request, HttpServletResponse response) 27 | throws ServletException, IOException { 28 | Users loginUser = (Users)request.getSession().getAttribute("loginUser"); 29 | List carItems = new ArrayList(); 30 | carItems = carService.ShowItemInCar(loginUser.getUserID()); 31 | System.out.println(carItems.size()); 32 | request.setAttribute("carItems", carItems); 33 | request.getRequestDispatcher("/WEB-INF/jsp/front/ShowCar.jsp").forward(request, response); 34 | } 35 | 36 | public void doPost(HttpServletRequest request, HttpServletResponse response) 37 | throws ServletException, IOException { 38 | this.doPost(request, response); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/servlet/deleteCarServlet.java: -------------------------------------------------------------------------------- 1 | package servlet; 2 | 3 | import java.io.IOException; 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 | 10 | import model.Users; 11 | 12 | import service.CarsService; 13 | import service.CarsServiceImpl; 14 | 15 | public class deleteCarServlet extends HttpServlet { 16 | 17 | private static final long serialVersionUID = -4054024674469520579L; 18 | private CarsService carsService = new CarsServiceImpl(); 19 | public void doGet(HttpServletRequest request, HttpServletResponse response) 20 | throws ServletException, IOException { 21 | String ids = request.getParameter("id"); 22 | String[] idsList = ids.split(","); 23 | int[] itemID = new int[idsList.length]; 24 | for(int i = 0 ; i < idsList.length ; i++){ 25 | itemID[i] = Integer.parseInt(idsList[i]); 26 | } 27 | Users loginUser = (Users)request.getSession().getAttribute("loginUser"); 28 | boolean flag = carsService.deleteItems(loginUser.getUserID(), itemID); 29 | if(flag==true){ 30 | response.sendRedirect(request.getContextPath()+"/servlet/ShowCarServlet"); 31 | }else{ 32 | response.sendRedirect("fail.jsp"); 33 | } 34 | } 35 | 36 | public void doPost(HttpServletRequest request, HttpServletResponse response) 37 | throws ServletException, IOException { 38 | this.doGet(request, response); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/service/ItemsServiceImpl.java: -------------------------------------------------------------------------------- 1 | package service; 2 | 3 | import java.util.List; 4 | 5 | import model.Items; 6 | import model.Pager; 7 | import dao.ItemsDao; 8 | import dao.ItemsDaoImpl; 9 | 10 | 11 | 12 | 13 | public class ItemsServiceImpl implements ItemsService { 14 | private ItemsDao itemsDao; 15 | 16 | public ItemsServiceImpl(){ 17 | itemsDao = new ItemsDaoImpl(); 18 | } 19 | 20 | //分页 21 | @Override 22 | public Pager findItems(Items searchModel, int pageNum, 23 | int pageSize) { 24 | Pager result = itemsDao.findItems(searchModel, pageNum, 25 | pageSize); 26 | return result; 27 | } 28 | 29 | //获取单个商品 30 | @Override 31 | public List getOneItem(int id) { 32 | List itemList = itemsDao.getOneItem(id); 33 | return itemList; 34 | } 35 | 36 | //更新商品热度 37 | @Override 38 | public boolean addItemHot(int id) { 39 | return itemsDao.addItemHot(id); 40 | } 41 | 42 | //购买商品 43 | @Override 44 | public boolean buyItem(int userID, Items buyItem, String buy_Time) { 45 | return itemsDao.buyItem(userID, buyItem, buy_Time); 46 | } 47 | 48 | //根据商品类型分页 49 | @Override 50 | public Pager typeItems(Items searchModel, int pageNum, int pageSize) { 51 | Pager result = itemsDao.typeItems(searchModel, pageNum, pageSize); 52 | return result; 53 | } 54 | 55 | //添加商品信息 56 | @Override 57 | public boolean addItem(Items additem) { 58 | boolean flag = itemsDao.addItem(additem); 59 | return flag; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/servlet/ImageServlet.java: -------------------------------------------------------------------------------- 1 | package servlet; 2 | 3 | import java.awt.Color; 4 | import java.awt.Graphics; 5 | import java.awt.image.BufferedImage; 6 | import java.io.IOException; 7 | import java.util.Random; 8 | 9 | import javax.imageio.ImageIO; 10 | import javax.servlet.http.HttpServlet; 11 | import javax.servlet.http.HttpServletRequest; 12 | import javax.servlet.http.HttpServletResponse; 13 | 14 | public class ImageServlet extends HttpServlet { 15 | 16 | private static final long serialVersionUID = -7704614981905775231L; 17 | 18 | public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException{ 19 | BufferedImage bi = new BufferedImage(68,22,BufferedImage.TYPE_INT_RGB); 20 | Graphics g = bi.getGraphics(); 21 | Color c = new Color(200, 200, 200); 22 | g.setColor(c); 23 | g.fillRect(0, 0, 68, 22); 24 | 25 | char[] ch = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toCharArray(); 26 | Random r = new Random(); 27 | int len=ch.length,index; 28 | StringBuffer sb = new StringBuffer(); 29 | for(int i=0; i<4; i++){ 30 | index = r.nextInt(len); 31 | g.setColor(new Color(r.nextInt(88),r.nextInt(188),r.nextInt(200))); 32 | g.drawString(ch[index]+"", (i*15)+3, 18); 33 | sb.append(ch[index]); 34 | } 35 | if(request.getSession().getAttribute("piccode")!=null){ 36 | request.getSession().removeAttribute("piccode"); 37 | } 38 | request.getSession().setAttribute("piccode", sb.toString()); 39 | ImageIO.write(bi, "JPG", response.getOutputStream()); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/servlet/ShowItemServlet.java: -------------------------------------------------------------------------------- 1 | package servlet; 2 | 3 | import java.io.IOException; 4 | import java.util.List; 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 | 11 | import model.Items; 12 | import service.ItemsService; 13 | import service.ItemsServiceImpl; 14 | 15 | 16 | public class ShowItemServlet extends HttpServlet { 17 | 18 | private static final long serialVersionUID = -5965679192471631050L; 19 | private ItemsService getOneItem = new ItemsServiceImpl(); 20 | 21 | public void doGet(HttpServletRequest request, HttpServletResponse response) 22 | throws ServletException, IOException { 23 | this.doPost(request, response); 24 | } 25 | 26 | public void doPost(HttpServletRequest request, HttpServletResponse response) 27 | throws ServletException, IOException { 28 | // 接收request里的参数 29 | int id = Integer.parseInt(request.getParameter("id")); 30 | List itemList =null; 31 | Items item = new Items(); 32 | //查询结果 33 | itemList = getOneItem.getOneItem(id); 34 | item = itemList.get(0); 35 | 36 | //更新商品热度 37 | boolean flag = getOneItem.addItemHot(id); 38 | if(flag==true){ 39 | // 返回结果到页面 40 | request.setAttribute("item", item); 41 | request.getRequestDispatcher("/WEB-INF/jsp/front/buy.jsp").forward(request, response); 42 | }else{ 43 | response.sendRedirect(request.getContextPath()+"/fail.jsp"); 44 | } 45 | 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/model/buy_items.java: -------------------------------------------------------------------------------- 1 | package model; 2 | 3 | 4 | public class buy_items { 5 | private int itemID;//商品ID 6 | private String buy_Time;//购买时间 7 | private int userID;//用户ID 8 | private int itemPrice;//商品价格 9 | private int itemNumber;//商品数量 10 | private String itemName;//商品名称 11 | 12 | 13 | public buy_items() { 14 | super(); 15 | } 16 | public buy_items(int itemID, String buy_Time, int userID, int itemPrice, 17 | int itemNumber, String itemName) { 18 | super(); 19 | this.itemID = itemID; 20 | this.buy_Time = buy_Time; 21 | this.userID = userID; 22 | this.itemPrice = itemPrice; 23 | this.itemNumber = itemNumber; 24 | this.itemName = itemName; 25 | } 26 | public int getItemID() { 27 | return itemID; 28 | } 29 | public void setItemID(int itemID) { 30 | this.itemID = itemID; 31 | } 32 | public String getBuy_Time() { 33 | return buy_Time; 34 | } 35 | public void setBuy_Time(String buy_Time) { 36 | this.buy_Time = buy_Time; 37 | } 38 | public int getUserID() { 39 | return userID; 40 | } 41 | public void setUserID(int userID) { 42 | this.userID = userID; 43 | } 44 | public int getItemPrice() { 45 | return itemPrice; 46 | } 47 | public void setItemPrice(int itemPrice) { 48 | this.itemPrice = itemPrice; 49 | } 50 | public int getItemNumber() { 51 | return itemNumber; 52 | } 53 | public void setItemNumber(int itemNumber) { 54 | this.itemNumber = itemNumber; 55 | } 56 | public String getItemName() { 57 | return itemName; 58 | } 59 | public void setItemName(String itemName) { 60 | this.itemName = itemName; 61 | } 62 | 63 | 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/model/Cars.java: -------------------------------------------------------------------------------- 1 | package model; 2 | 3 | public class Cars { 4 | private int itemID; 5 | private int userID; 6 | private int itemPrice; 7 | private String itemName; 8 | private String itemImage; 9 | private int itemNumber; 10 | 11 | @Override 12 | public String toString() { 13 | return "Cars [itemID=" + itemID + ", userID=" + userID + ", itemPrice=" 14 | + itemPrice + ", itemName=" + itemName + ", itemImage=" 15 | + itemImage + ", itemNumber=" + itemNumber + "]"; 16 | } 17 | public Cars() { 18 | super(); 19 | } 20 | public Cars(int itemID, int userID, int itemPrice, String itemName, 21 | String itemImage, int itemNumber) { 22 | super(); 23 | this.itemID = itemID; 24 | this.userID = userID; 25 | this.itemPrice = itemPrice; 26 | this.itemName = itemName; 27 | this.itemImage = itemImage; 28 | this.itemNumber = itemNumber; 29 | } 30 | public int getItemID() { 31 | return itemID; 32 | } 33 | public void setItemID(int itemID) { 34 | this.itemID = itemID; 35 | } 36 | public int getUserID() { 37 | return userID; 38 | } 39 | public void setUserID(int userID) { 40 | this.userID = userID; 41 | } 42 | public int getItemPrice() { 43 | return itemPrice; 44 | } 45 | public void setItemPrice(int itemPrice) { 46 | this.itemPrice = itemPrice; 47 | } 48 | public String getItemName() { 49 | return itemName; 50 | } 51 | public void setItemName(String itemName) { 52 | this.itemName = itemName; 53 | } 54 | public String getItemImage() { 55 | return itemImage; 56 | } 57 | public void setItemImage(String itemImage) { 58 | this.itemImage = itemImage; 59 | } 60 | public int getItemNumber() { 61 | return itemNumber; 62 | } 63 | public void setItemNumber(int itemNumber) { 64 | this.itemNumber = itemNumber; 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /WebRoot/css/normalize.css: -------------------------------------------------------------------------------- 1 | article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block;}audio,canvas,video{display:inline-block;}audio:not([controls]){display:none;height:0;}[hidden]{display:none;}html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;}body{margin:0;}a:focus{outline:thin dotted;}a:active,a:hover{outline:0;}h1{font-size:2em;margin:0.67em 0;}abbr[title]{border-bottom:1px dotted;}b,strong{font-weight:bold;}dfn{font-style:italic;}hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0;}mark{background:#ff0;color:#000;}code,kbd,pre,samp{font-family:monospace,serif;font-size:1em;}pre{white-space:pre-wrap;}q{quotes:"\201C" "\201D" "\2018" "\2019";}small{font-size:80%;}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline;}sup{top:-0.5em;}sub{bottom:-0.25em;}img{border:0;}svg:not(:root){overflow:hidden;}figure{margin:0;}fieldset{border:1px solid #c0c0c0;margin:0 2px;padding:0.35em 0.625em 0.75em;}legend{border:0;padding:0;}button,input,select,textarea{font-family:inherit;font-size:100%;margin:0;}button,input{line-height:normal;}button,select{text-transform:none;}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer;}button[disabled],html input[disabled]{cursor:default;}input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0;}input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box;}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none;}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0;}textarea{overflow:auto;vertical-align:top;}table{border-collapse:collapse;border-spacing:0;} -------------------------------------------------------------------------------- /WebRoot/fonts/icomoon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Generated by IcoMoon 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/model/Users.java: -------------------------------------------------------------------------------- 1 | package model; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * 用户信息的模型类 7 | * @author zhouliang 8 | * 9 | */ 10 | public class Users { 11 | private int userID; 12 | private String username; 13 | private String password; 14 | private String contact;//联系方式 15 | private String address;//地址 16 | public int getUserID() { 17 | return userID; 18 | } 19 | public void setUserID(int userID) { 20 | this.userID = userID; 21 | } 22 | public String getUsername() { 23 | return username; 24 | } 25 | public void setUsername(String username) { 26 | this.username = username; 27 | } 28 | public String getPassword() { 29 | return password; 30 | } 31 | public void setPassword(String password) { 32 | this.password = password; 33 | } 34 | public String getContact() { 35 | return contact; 36 | } 37 | public void setContact(String contact) { 38 | this.contact = contact; 39 | } 40 | public String getAddress() { 41 | return address; 42 | } 43 | public void setAddress(String address) { 44 | this.address = address; 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | return "users [userID=" + userID + ", username=" + username 50 | + ", password=" + password + ", contact=" + contact 51 | + ", address=" + address + "]"; 52 | } 53 | public Users() { 54 | super(); 55 | } 56 | public Users(int userID, String username, String password, String contact, 57 | String address) { 58 | super(); 59 | this.userID = userID; 60 | this.username = username; 61 | this.password = password; 62 | this.contact = contact; 63 | this.address = address; 64 | } 65 | public Users(Map map) { 66 | this.userID = (Integer)map.get("userID"); 67 | this.username = (String)map.get("username"); 68 | this.password = (String)map.get("password"); 69 | this.contact = (String)map.get("contact"); 70 | this.address = (String)map.get("address"); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | demo1 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.wst.common.project.facet.core.builder 10 | 11 | 12 | 13 | 14 | org.eclipse.wst.jsdt.core.javascriptValidator 15 | 16 | 17 | 18 | 19 | com.genuitec.eclipse.j2eedt.core.WebClasspathBuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.jdt.core.javabuilder 25 | 26 | 27 | 28 | 29 | com.genuitec.eclipse.j2eedt.core.J2EEProjectValidator 30 | 31 | 32 | 33 | 34 | com.genuitec.eclipse.j2eedt.core.DeploymentDescriptorValidator 35 | 36 | 37 | 38 | 39 | org.eclipse.wst.validation.validationbuilder 40 | 41 | 42 | 43 | 44 | com.genuitec.eclipse.ast.deploy.core.DeploymentBuilder 45 | 46 | 47 | 48 | 49 | 50 | com.genuitec.eclipse.ast.deploy.core.deploymentnature 51 | org.eclipse.jem.workbench.JavaEMFNature 52 | com.genuitec.eclipse.j2eedt.core.webnature 53 | org.eclipse.jdt.core.javanature 54 | org.eclipse.wst.jsdt.core.jsNature 55 | org.eclipse.wst.common.project.facet.core.nature 56 | org.eclipse.wst.common.modulecore.ModuleCoreNature 57 | 58 | 59 | -------------------------------------------------------------------------------- /src/test/ItemTest.java: -------------------------------------------------------------------------------- 1 | package test; 2 | 3 | 4 | 5 | import java.util.List; 6 | import java.util.Random; 7 | 8 | import model.Items; 9 | import model.Pager; 10 | 11 | import org.junit.Test; 12 | 13 | import dao.ItemsDaoImpl; 14 | import dao.SortDao; 15 | import dao.SortDaoImpl; 16 | 17 | public class ItemTest { 18 | @Test 19 | public void addItemHot(){ 20 | ItemsDaoImpl item = new ItemsDaoImpl(); 21 | //item.addItemHot(35); 22 | item.addItemHot(34); 23 | } 24 | 25 | @Test 26 | public void TypeSubmit(){ 27 | ItemsDaoImpl item = new ItemsDaoImpl(); 28 | Items searchModel = new Items(); 29 | searchModel.setType("数码产品"); 30 | Pager result = item.typeItems(searchModel, 1, 4); 31 | List items = result.getDataList(); 32 | System.out.println(); 33 | for (Items items2 : items) { 34 | System.out.println(items2.toString()); 35 | } 36 | System.out.println(result.getPageSize()); 37 | System.out.println(result.getTotalPage()); 38 | System.out.println(result.getTotalRecord()); 39 | } 40 | 41 | @Test 42 | public void random(){ 43 | 44 | for(int n = 0 ; n < 50 ; n++){ 45 | Random ran = new Random(); 46 | int[] num = new int[11]; 47 | num[0]=1; 48 | num[1]=ran.nextInt(5)+5; 49 | for(int i = 2 ; i < 11 ; i++){ 50 | int j = ran.nextInt(10); 51 | num[i] = j; 52 | } 53 | StringBuffer str = new StringBuffer(); 54 | for (int i = 0; i < num.length; i++) { 55 | str.append(Integer.toString(num[i])); 56 | } 57 | System.out.println(str.toString()); 58 | } 59 | } 60 | 61 | @Test 62 | public void SortByPrice(){ 63 | SortDao sortDao = new SortDaoImpl(); 64 | Items item = new Items(); 65 | item.setType("美妆服饰"); 66 | sortDao.SortByPrice(item, 1, 16); 67 | } 68 | @Test 69 | public void SortByHot(){ 70 | SortDao sortDao = new SortDaoImpl(); 71 | Items item = new Items(); 72 | item.setType("美妆服饰"); 73 | sortDao.SortByHot(item, 1, 16); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/servlet/LoginServlet.java: -------------------------------------------------------------------------------- 1 | package servlet; 2 | 3 | import java.io.IOException; 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 | 11 | import service.UserService; 12 | import service.UserServiceImpl; 13 | 14 | import model.Users; 15 | /** 16 | * 用户登陆 17 | * @author zhouliang 18 | * 19 | */ 20 | public class LoginServlet extends HttpServlet { 21 | 22 | private static final long serialVersionUID = 6264381047408967619L; 23 | private UserService loginService = new UserServiceImpl(); 24 | 25 | public void doGet(HttpServletRequest request, HttpServletResponse response) 26 | throws ServletException, IOException { 27 | this.doPost(request, response); 28 | } 29 | 30 | 31 | public void doPost(HttpServletRequest request, HttpServletResponse response) 32 | throws ServletException, IOException { 33 | //未过滤的请求要统一字符集 34 | request.setCharacterEncoding("UTF-8"); 35 | response.setCharacterEncoding("UTF-8"); 36 | 37 | //第一次登陆 38 | if(request.getSession().getAttribute("loginUser")==null){ 39 | //获取用户名和密码 40 | String username = (String) request.getParameter("username"); 41 | String password = (String) request.getParameter("password"); 42 | 43 | Users user = new Users(); 44 | user.setUsername(username); 45 | user.setPassword(password); 46 | 47 | Users loginUser = new Users(); 48 | //验证通过跳转至首页,不通过跳转至登陆页面 49 | loginUser = loginService.findAllUsers(user); 50 | if(loginUser!=null){ 51 | HttpSession session = request.getSession(); 52 | session.setAttribute("loginUser",loginUser); 53 | response.sendRedirect(request.getContextPath()+"/HomePage.jsp"); 54 | }else{ 55 | response.sendRedirect(request.getContextPath()+"/fail.jsp"); 56 | } 57 | }else{ 58 | response.sendRedirect(request.getContextPath()+"/HomePage.jsp"); 59 | } 60 | 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/filter/LoginFilter.java: -------------------------------------------------------------------------------- 1 | package filter; 2 | 3 | import java.io.IOException; 4 | 5 | import javax.servlet.Filter; 6 | import javax.servlet.FilterChain; 7 | import javax.servlet.FilterConfig; 8 | import javax.servlet.ServletException; 9 | import javax.servlet.ServletRequest; 10 | import javax.servlet.ServletResponse; 11 | import javax.servlet.http.HttpServletRequest; 12 | import javax.servlet.http.HttpServletResponse; 13 | import javax.servlet.http.HttpSession; 14 | 15 | /** 16 | * 登陆过滤器 17 | * @author zhouliang 18 | * 19 | */ 20 | public class LoginFilter implements Filter { 21 | 22 | private FilterConfig config; 23 | @Override 24 | public void destroy() { 25 | 26 | } 27 | 28 | @Override 29 | public void doFilter(ServletRequest arg0, ServletResponse arg1,FilterChain arg2) throws IOException, ServletException { 30 | HttpServletRequest request = (HttpServletRequest) arg0; 31 | HttpServletResponse response = (HttpServletResponse) arg1; 32 | HttpSession session = request.getSession(); 33 | String noLoginPaths = config.getInitParameter("noLoginPaths"); 34 | 35 | String charset = config.getInitParameter("charset"); 36 | if(charset==null){ 37 | charset = "UTF-8"; 38 | } 39 | response.setContentType("text/html;charset=utf-8"); 40 | //加载过滤参数 41 | if(noLoginPaths!=null){ 42 | String[] strArray = noLoginPaths.split(";"); 43 | for (int i = 0; i < strArray.length; i++) { 44 | 45 | if(strArray[i]==null || "".equals(strArray[i]))continue; 46 | 47 | if(request.getRequestURI().indexOf(strArray[i])!=-1 ){ 48 | arg2.doFilter(arg0, arg1); 49 | return; 50 | } 51 | } 52 | 53 | } 54 | //为servlet设置统一的字符集 55 | request.setCharacterEncoding(charset); 56 | response.setCharacterEncoding(charset); 57 | 58 | //过滤 59 | if(session.getAttribute("loginUser")!=null){ 60 | arg2.doFilter(arg0, arg1); 61 | }else{ 62 | response.sendRedirect(request.getContextPath()+"/Login.jsp"); 63 | } 64 | } 65 | 66 | @Override 67 | public void init(FilterConfig arg0) throws ServletException { 68 | config = arg0; 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/servlet/registerServlet.java: -------------------------------------------------------------------------------- 1 | package servlet; 2 | 3 | import java.io.IOException; 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 | 10 | import service.UserService; 11 | import service.UserServiceImpl; 12 | 13 | 14 | import model.Users; 15 | 16 | public class registerServlet extends HttpServlet { 17 | 18 | private static final long serialVersionUID = 2217052105667659254L; 19 | private UserService registerservice = new UserServiceImpl(); 20 | 21 | public void doGet(HttpServletRequest request, HttpServletResponse response) 22 | throws ServletException, IOException { 23 | this.doPost(request, response); 24 | } 25 | 26 | public void doPost(HttpServletRequest request, HttpServletResponse response) 27 | throws ServletException, IOException { 28 | //未过滤的请求要统一字符集 29 | request.setCharacterEncoding("UTF-8"); 30 | response.setCharacterEncoding("UTF-8"); 31 | // 获取验证码 32 | String piccode = (String) request.getSession().getAttribute("piccode"); 33 | String checkcode = request.getParameter("checkcode"); 34 | checkcode = checkcode.toUpperCase(); 35 | if (!checkcode.equals(piccode)) { 36 | response.getWriter().write(""); 37 | response.getWriter().flush(); 38 | response.getWriter().close(); 39 | }else{ 40 | Users registerUser = new Users(); 41 | String username = request.getParameter("username"); 42 | String password = request.getParameter("password"); 43 | String contact = request.getParameter("contact"); 44 | String address = request.getParameter("address"); 45 | System.out.println(username); 46 | registerUser.setUsername(username); 47 | registerUser.setPassword(password); 48 | registerUser.setContact(contact); 49 | registerUser.setAddress(address); 50 | boolean flag = registerservice.registerUser(registerUser); 51 | if(flag==true){ 52 | request.setAttribute("username", username); 53 | request.setAttribute("password", password); 54 | request.getRequestDispatcher("/servlet/LoginServlet").forward(request, response); 55 | }else{ 56 | request.getRequestDispatcher("/fail.jsp").forward(request, 57 | response); 58 | } 59 | } 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/servlet/BuyServlet.java: -------------------------------------------------------------------------------- 1 | package servlet; 2 | 3 | import java.io.IOException; 4 | import java.text.SimpleDateFormat; 5 | import java.util.Date; 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 | 12 | import model.Items; 13 | import model.Users; 14 | 15 | import service.ItemsService; 16 | import service.ItemsServiceImpl; 17 | 18 | public class BuyServlet extends HttpServlet { 19 | 20 | 21 | private static final long serialVersionUID = 6066135226388011068L; 22 | private ItemsService itemsService = new ItemsServiceImpl(); 23 | 24 | public void doGet(HttpServletRequest request, HttpServletResponse response) 25 | throws ServletException, IOException { 26 | this.doPost(request, response); 27 | } 28 | 29 | 30 | public void doPost(HttpServletRequest request, HttpServletResponse response) 31 | throws ServletException, IOException { 32 | // 统一字符集 33 | request.setCharacterEncoding("UTF-8"); 34 | response.setCharacterEncoding("UTF-8"); 35 | 36 | //接收参数,已经登录的用户才能购买 37 | Users user = (Users) request.getSession().getAttribute("loginUser"); 38 | int itemID = Integer.parseInt(request.getParameter("itemID")); 39 | System.out.println(itemID); 40 | int itemPrice = Integer.parseInt(request.getParameter("itemPrice")); 41 | int number = 1; 42 | 43 | //处理get字符串乱码 44 | String itemName = request.getParameter("itemName"); 45 | String Name = new String(itemName.getBytes("iso8859-1"),"UTF-8"); 46 | 47 | //组装购买信息 48 | Items buyItem = new Items(); 49 | buyItem.setId(itemID); 50 | buyItem.setPrice(itemPrice); 51 | buyItem.setName(Name); 52 | buyItem.setNumber(number); 53 | 54 | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式 55 | String buy_Time = df.format(new Date());// new Date()为获取当前系统时间 56 | boolean flag = itemsService.buyItem(user.getUserID(), buyItem, buy_Time); 57 | if(flag==true){ 58 | response.getWriter().write(""); 59 | response.getWriter().flush(); 60 | response.getWriter().close(); 61 | }else{ 62 | response.sendRedirect(request.getContextPath()+"/fail.jsp"); 63 | } 64 | 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /src/servlet/LimitByTypeServlet.java: -------------------------------------------------------------------------------- 1 | package servlet; 2 | 3 | import java.io.IOException; 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 | 10 | import model.Items; 11 | import model.Pager; 12 | 13 | import service.ItemsService; 14 | import service.ItemsServiceImpl; 15 | import util.Constant; 16 | import util.StringUtil; 17 | 18 | public class LimitByTypeServlet extends HttpServlet { 19 | 20 | private static final long serialVersionUID = -7173405129986617053L; 21 | private ItemsService itemsService = new ItemsServiceImpl(); 22 | 23 | public void doGet(HttpServletRequest request, HttpServletResponse response) 24 | throws ServletException, IOException { 25 | doPost(request, response); 26 | } 27 | 28 | public void doPost(HttpServletRequest request, HttpServletResponse response) 29 | throws ServletException, IOException { 30 | // 未过滤的请求要统一字符集 31 | request.setCharacterEncoding("UTF-8"); 32 | response.setCharacterEncoding("UTF-8"); 33 | // 接收request里的参数 34 | String itemtype = request.getParameter("itemType"); // 商品名称 35 | //处理get字符串乱码 36 | String type = new String(itemtype.getBytes("iso8859-1"),"UTF-8"); 37 | 38 | // 校验pageNum参数输入合法性 39 | String pageNumStr = request.getParameter("pageNum"); 40 | if (pageNumStr != null && !StringUtil.isNum(pageNumStr)) { 41 | request.setAttribute("errorMsg", "参数传输错误"); 42 | request.getRequestDispatcher("fail.jsp").forward(request, response); 43 | return; 44 | } 45 | 46 | int pageNum = Constant.DEFAULT_PAGE_NUM; // 显示第几页数据 47 | if (pageNumStr != null && !"".equals(pageNumStr.trim())) { 48 | pageNum = Integer.parseInt(pageNumStr); 49 | } 50 | 51 | int pageSize = Constant.DEFAULT_PAGE_SIZE; // 每页显示多少条记录 52 | String pageSizeStr = request.getParameter("pageSize"); 53 | if (pageSizeStr != null && !"".equals(pageSizeStr.trim())) { 54 | pageSize = Integer.parseInt(pageSizeStr); 55 | } 56 | 57 | // 组装查询条件 58 | Items searchModel = new Items(); 59 | if (type != null && !"".equals(type.trim())) { 60 | searchModel.setType(type); 61 | } 62 | searchModel.setHot(0); 63 | // 调用service 获取查询结果 64 | Pager result = itemsService.typeItems(searchModel, pageNum, 65 | pageSize); 66 | // 返回结果到页面 67 | request.setAttribute("result", result); 68 | request.setAttribute("itemType", type); 69 | request.getRequestDispatcher("/ShowType.jsp").forward(request, response); 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/servlet/LimitItemsServlet.java: -------------------------------------------------------------------------------- 1 | package servlet; 2 | 3 | import java.io.IOException; 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 | 10 | import model.Items; 11 | import model.Pager; 12 | import service.ItemsService; 13 | import service.ItemsServiceImpl; 14 | import util.Constant; 15 | import util.StringUtil; 16 | 17 | 18 | public class LimitItemsServlet extends HttpServlet { 19 | 20 | private static final long serialVersionUID = 2659038734485387542L; 21 | private ItemsService itemsService = new ItemsServiceImpl(); 22 | 23 | public void doGet(HttpServletRequest request, HttpServletResponse response) 24 | throws ServletException, IOException { 25 | 26 | doPost(request, response); 27 | } 28 | 29 | public void doPost(HttpServletRequest request, HttpServletResponse response) 30 | throws ServletException, IOException { 31 | //未过滤的请求要统一字符集 32 | request.setCharacterEncoding("UTF-8"); 33 | response.setCharacterEncoding("UTF-8"); 34 | // 接收request里的参数 35 | String name; 36 | if(request.getParameter("itemName")!=null){ 37 | String name1 = request.getParameter("itemName"); //商品名称 38 | name = new String(name1.getBytes("iso8859-1"),"UTF-8"); 39 | System.out.println(name); 40 | }else{ 41 | name = null; 42 | } 43 | // 校验pageNum参数输入合法性 44 | String pageNumStr = request.getParameter("pageNum"); 45 | if(pageNumStr !=null && !StringUtil.isNum(pageNumStr)){ 46 | request.setAttribute("errorMsg", "参数传输错误"); 47 | request.getRequestDispatcher("fail.jsp").forward(request, response); 48 | return; 49 | } 50 | 51 | int pageNum = Constant.DEFAULT_PAGE_NUM; //显示第几页数据 52 | if(pageNumStr!=null && !"".equals(pageNumStr.trim())){ 53 | pageNum = Integer.parseInt(pageNumStr); 54 | } 55 | 56 | int pageSize = Constant.DEFAULT_PAGE_SIZE; // 每页显示多少条记录 57 | String pageSizeStr = request.getParameter("pageSize"); 58 | if(pageSizeStr!=null && !"".equals(pageSizeStr.trim())){ 59 | pageSize = Integer.parseInt(pageSizeStr); 60 | } 61 | 62 | // 组装查询条件 63 | Items searchModel = new Items(); 64 | if(name!=null&&!"".equals(name.trim())){ 65 | searchModel.setName(name); 66 | } 67 | searchModel.setHot(0); 68 | //调用service 获取查询结果 69 | Pager result = itemsService.findItems(searchModel, 70 | pageNum, pageSize); 71 | // 返回结果到页面 72 | request.setAttribute("result", result); 73 | request.getRequestDispatcher("/Show.jsp").forward(request, response); 74 | 75 | } 76 | 77 | } 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /src/servlet/CarServlet.java: -------------------------------------------------------------------------------- 1 | package servlet; 2 | 3 | import java.io.IOException; 4 | import java.util.List; 5 | 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 | 12 | import service.CarsService; 13 | import service.CarsServiceImpl; 14 | 15 | 16 | 17 | import model.Items; 18 | import model.Users; 19 | 20 | public class CarServlet extends HttpServlet { 21 | 22 | private static final long serialVersionUID = -3414634011792102743L; 23 | private CarsService carService = new CarsServiceImpl(); 24 | public void doGet(HttpServletRequest request, HttpServletResponse response) 25 | throws ServletException, IOException { 26 | this.doPost(request, response); 27 | } 28 | 29 | public void doPost(HttpServletRequest request, HttpServletResponse response) 30 | throws ServletException, IOException { 31 | // 统一字符集 32 | request.setCharacterEncoding("UTF-8"); 33 | response.setCharacterEncoding("UTF-8"); 34 | 35 | //接收参数,已经登录的用户才能购买 36 | Users user = (Users) request.getSession().getAttribute("loginUser"); 37 | int itemID = Integer.parseInt(request.getParameter("itemID")); 38 | System.out.println(itemID); 39 | int itemPrice = Integer.parseInt(request.getParameter("itemPrice")); 40 | int number = 1; 41 | 42 | //处理get字符串乱码 43 | String itemName = request.getParameter("itemName"); 44 | String Name = new String(itemName.getBytes("iso8859-1"),"UTF-8"); 45 | String itemImage = request.getParameter("itemImage"); 46 | String image = new String(itemImage.getBytes("iso8859-1"),"UTF-8"); 47 | 48 | 49 | Items item = new Items(); 50 | item.setId(itemID); 51 | item.setPrice(itemPrice); 52 | item.setName(Name); 53 | item.setImage(image); 54 | //判断购物车中是否有同ID的商品 55 | List ItemsCar = carService.ShowItemInCar(user.getUserID()); 56 | boolean buyOrUpdate = false; 57 | for (Items itemCar : ItemsCar) { 58 | if(itemCar.getId()==itemID){ 59 | buyOrUpdate = true; 60 | } 61 | } 62 | if(buyOrUpdate==true){ 63 | //增加购物车中此商品的数量 64 | boolean flag = carService.updateItemInCar(itemID, user.getUserID(), number); 65 | if(flag==true){ 66 | response.sendRedirect(request.getContextPath()+"/HomePage.jsp"); 67 | }else{ 68 | response.sendRedirect(request.getContextPath()+"/fail.jsp"); 69 | } 70 | }else{ 71 | //在购物车中增加一件新的商品 72 | boolean flag = carService.addItemToCar(user.getUserID(), item,number); 73 | if(flag==true){ 74 | response.sendRedirect(request.getContextPath()+"/HomePage.jsp"); 75 | }else{ 76 | response.sendRedirect(request.getContextPath()+"/fail.jsp"); 77 | } 78 | } 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /WebRoot/backresource/style1.css: -------------------------------------------------------------------------------- 1 | @charset "utf-8"; 2 | /* CSS Document */ 3 | .top{ width:100%; background-color:#234686; padding:20px 0;margin:0 auto; } 4 | *{ font-size:12px; font-family:"微软雅黑"} 5 | .logo{margin-left:40px;} 6 | ul{padding:0;} 7 | dl{margin:0;} 8 | img{border:none;} 9 | dd{padding:0; margin:0} 10 | body{margin:0;} 11 | a{text-decoration:none !important;} 12 | li{list-style:none;} 13 | .clearfix:after, .clearfix:before{ display: table; 14 | content: " " 15 | } 16 | .nav{text-align:center; float:right; margin-right:40px; margin-bottom:0; position: absolute; 17 | top: 0; 18 | right: 0;} 19 | .nav a{color:#fff;} 20 | .nav li{float:left; margin-right:40px;} 21 | .hyy p{text-align:center; font-size:50px; color:red; padding-top:50px;} 22 | .content{ width:100%;margin:0 auto; position:relative;} 23 | .left-column{width:15%; text-align:center; float:left; background-color:#e1e7f5; height:680px;} 24 | .left-column h5{color:#fff; background-color:#3399fe; font-size:18px; border-radius:10px; margin:0 20px; padding:4px 15px; height:20px; line-height:18px;} 25 | .service{height:45px; background-color:#b5d6f9; padding-top:15px;} 26 | .call dt{background-color:#e1e7f5; line-height:35px; font-size:14px; border-bottom:1px dashed #c4c9cf;} 27 | .main{border-top:1px dashed #ffffff;} 28 | .call dd{line-height:32px; background-color:#d5dbe9;} 29 | .call dd a{color:#292728;} 30 | .current{background-color:#f8f8f8 !important;} 31 | .current a{color:#fd9363 !important;} 32 | .right-content{width:85%; position:relative; position:absolute; left:15%; background-color:#f8f8f8;} 33 | .ck p{background-color:#f1f1f1; font-size:14px; color:#191917; margin:0; height:60px;} 34 | .ck p span{ position:absolute; top:30px; left:40px; background-color:#d0d6e4; line-height:30px; padding:0 10px;} 35 | .ck{clear:both;} 36 | .srxz{background-color:#f8f8f8; padding-left:40px;} 37 | input, select{background-color:#f1f1f1; border:1px solid #c1c1c1; padding-left:10px; margin:10px; height:30px; border-radius:3px; min-width:200px;} 38 | .srxz span{padding-right:5px;} 39 | .sub{float:right; background-color:#1e4a91; padding:5px 20px; margin-right:30px; border-radius:3px;} 40 | .sub a{color:#fff;} 41 | 42 | .daohanglink{ 43 | height:40px; line-height:40px; vertical-align:middle; 44 | background-color:rgb(248,248,248); 45 | margin-bottom:15px; 46 | } 47 | .daohanglink span{ 48 | margin-left:5px;} 49 | .daohang{ 50 | float: left; 51 | height: 15px; 52 | width: 5px; 53 | border-left-width: 5px; 54 | border-left-style: solid; 55 | border-left-color: #036; 56 | margin-top:12px; 57 | margin-left:15px; 58 | } 59 | .inner_content{width:85%; padding-left:40px; } 60 | .brown{text-align:center} 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /src/dao/UserDaoImpl.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import java.sql.SQLException; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | import util.JdbcUtil; 9 | 10 | import model.Users; 11 | 12 | public class UserDaoImpl implements UserDao { 13 | 14 | @Override 15 | public List findAllUsers(Users user) { 16 | //sql查询的参数 17 | List paramList = new ArrayList(); 18 | 19 | //查询结果返回的Users 20 | List UserList = new ArrayList(); 21 | StringBuilder sql = new StringBuilder( 22 | "select * from users where username=? and password=? "); 23 | //添加查询参数 24 | paramList.add(user.getUsername()); 25 | paramList.add(user.getPassword()); 26 | JdbcUtil jdbcUtil = null; 27 | try { 28 | jdbcUtil = new JdbcUtil(); 29 | jdbcUtil.getConnection(); // 获取数据库链接 30 | 31 | // 获取查询的用户记录 32 | List> listResult = jdbcUtil.findResult(sql.toString(), paramList); 33 | if (listResult != null) { 34 | for (Map map : listResult) { 35 | Users u = new Users(map); 36 | UserList.add(u); 37 | System.out.println("用户检验成功!"+u.toString()); 38 | } 39 | } 40 | } catch (SQLException e) { 41 | throw new RuntimeException("查询单个用户信息异常!", e); 42 | } finally { 43 | if (jdbcUtil != null) { 44 | jdbcUtil.releaseConn(); // 释放资源 45 | } 46 | } 47 | return UserList; 48 | } 49 | 50 | 51 | @Override 52 | public boolean registerUser(Users registerUser) { 53 | 54 | List paramList = new ArrayList(); 55 | StringBuilder sql = new StringBuilder( 56 | "insert into users(username,password,contact,address) values(?,?,?,?)"); 57 | 58 | String username = registerUser.getUsername(); 59 | if (username != null && !username.equals("")) { 60 | paramList.add(username); 61 | } 62 | String password = registerUser.getPassword(); 63 | if (password != null && !password.equals("")) { 64 | paramList.add(password); 65 | } 66 | String contact = registerUser.getContact(); 67 | if (contact != null && !contact.equals("")) { 68 | paramList.add(contact); 69 | } 70 | String address = registerUser.getAddress(); 71 | if (address != null && !address.equals("")) { 72 | paramList.add(address); 73 | } 74 | 75 | JdbcUtil jdbcUtil = null; 76 | try { 77 | jdbcUtil = new JdbcUtil(); 78 | jdbcUtil.getConnection(); // 获取数据库链接 79 | 80 | // 添加用户信息 81 | boolean flag = jdbcUtil.updateByPreparedStatement(sql.toString(), paramList); 82 | if(flag==true){ 83 | System.out.println("添加的用户信息:"+registerUser.toString()); 84 | } 85 | return flag; 86 | } catch (SQLException e) { 87 | throw new RuntimeException("查询所有数据异常!", e); 88 | } finally { 89 | if (jdbcUtil != null) { 90 | jdbcUtil.releaseConn(); // 一定要释放资源 91 | } 92 | } 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /src/model/Pager.java: -------------------------------------------------------------------------------- 1 | package model; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | public class Pager implements Serializable { 7 | 8 | private static final long serialVersionUID = -8741766802354222579L; 9 | 10 | private int pageSize; // 每页显示多少条记录 11 | 12 | private int currentPage; //当前是第几页数据 13 | 14 | private int totalRecord; // 一共多少条记录 15 | 16 | private int totalPage; // 一共多少页记录 17 | 18 | private List dataList; //要显示的数据 19 | 20 | public Pager(int pageNum, int pageSize, List sourceList){ 21 | if(sourceList == null || sourceList.isEmpty()){ 22 | return; 23 | } 24 | 25 | // 总记录条数 26 | this.totalRecord = sourceList.size(); 27 | 28 | // 每页显示多少条记录 29 | this.pageSize = pageSize; 30 | 31 | //获取总页数 32 | this.totalPage = this.totalRecord / this.pageSize; 33 | if(this.totalRecord % this.pageSize !=0){ 34 | this.totalPage = this.totalPage + 1; 35 | } 36 | 37 | // 当前第几页数据 38 | this.currentPage = this.totalPage < pageNum ? this.totalPage : pageNum; 39 | 40 | // 起始索引 41 | int fromIndex = this.pageSize * (this.currentPage -1); 42 | 43 | // 结束索引 44 | int toIndex = this.pageSize * this.currentPage > this.totalRecord ? this.totalRecord : this.pageSize * this.currentPage; 45 | 46 | this.dataList = sourceList.subList(fromIndex, toIndex); 47 | } 48 | 49 | public Pager(){ 50 | 51 | } 52 | 53 | public Pager(int pageSize, int currentPage, int totalRecord, int totalPage, 54 | List dataList) { 55 | super(); 56 | this.pageSize = pageSize; 57 | this.currentPage = currentPage; 58 | this.totalRecord = totalRecord; 59 | this.totalPage = totalPage; 60 | this.dataList = dataList; 61 | } 62 | 63 | public int getPageSize() { 64 | return pageSize; 65 | } 66 | 67 | public void setPageSize(int pageSize) { 68 | this.pageSize = pageSize; 69 | } 70 | 71 | public int getCurrentPage() { 72 | return currentPage; 73 | } 74 | 75 | public void setCurrentPage(int currentPage) { 76 | this.currentPage = currentPage; 77 | } 78 | 79 | public int getTotalRecord() { 80 | return totalRecord; 81 | } 82 | 83 | public void setTotalRecord(int totalRecord) { 84 | this.totalRecord = totalRecord; 85 | } 86 | 87 | public int getTotalPage() { 88 | return totalPage; 89 | } 90 | 91 | public void setTotalPage(int totalPage) { 92 | this.totalPage = totalPage; 93 | } 94 | 95 | public List getDataList() { 96 | return dataList; 97 | } 98 | 99 | public void setDataList(List dataList) { 100 | this.dataList = dataList; 101 | } 102 | 103 | @Override 104 | public String toString() { 105 | return "Pager [pageSize=" + pageSize + ", currentPage=" + currentPage 106 | + ", totalRecord=" + totalRecord + ", totalPage=" + totalPage 107 | + ", dataList=" + dataList + "]"; 108 | } 109 | 110 | } 111 | -------------------------------------------------------------------------------- /WebRoot/backresource/date.js: -------------------------------------------------------------------------------- 1 | 2 | function setTab(name,cursel){ 3 | 4 | cursel_0=cursel; 5 | 6 | for(var i=1; i<=links_len; i++){ 7 | 8 | var menu = document.getElementById(name+i); 9 | var medo = document.getElementById(name+i); 10 | var medo1 = document.getElementById(name+i); 11 | /*var medo2 = document.getElementById(name+i);*/ 12 | var medo3 = document.getElementById(name+i); 13 | var medo4 = document.getElementById(name+i); 14 | 15 | var meduo4 = document.getElementById("con_"+name+"_"+i); 16 | var meduo3 = document.getElementById("con_"+name+"_"+i); 17 | /*var meduo2 = document.getElementById("con_"+name+"_"+i);*/ 18 | var meduo1 = document.getElementById("con_"+name+"_"+i); 19 | var menudiv = document.getElementById("con_"+name+"_"+i); 20 | var meduo = document.getElementById("con_"+name+"_"+i); 21 | if(i==cursel){ 22 | 23 | menu.className="off"; 24 | medo.className="off"; 25 | medo1.className="off"; 26 | /*medo2.className="off";*/ 27 | medo3.className="off"; 28 | medo4.className="off"; 29 | 30 | meduo4.style.display="block"; 31 | meduo3.style.display="block"; 32 | /*meduo2.style.display="block";*/ 33 | meduo1.style.display="block"; 34 | meduo.style.display="block"; 35 | menudiv.style.display="block"; 36 | 37 | } 38 | 39 | else{ 40 | 41 | menu.className=""; 42 | medo.className=""; 43 | /*medo2.className="";*/ 44 | medo3.className=""; 45 | medo4.className=""; 46 | medo1.className=""; 47 | 48 | meduo1.style.display="none"; 49 | meduo4.style.display="none"; 50 | meduo3.style.display="none"; 51 | /*meduo2.style.display="none"*/ 52 | meduo.style.display="none"; 53 | menudiv.style.display="none"; 54 | 55 | } 56 | 57 | } 58 | 59 | } 60 | 61 | function Next(){ 62 | 63 | cursel_0++; 64 | 65 | if (cursel_0>links_len)cursel_0=1 66 | 67 | setTab(name_0,cursel_0); 68 | 69 | } 70 | 71 | var name_0='one'; 72 | var name_0='column'; 73 | var name_0='colum'; 74 | var name_0='colunm'; 75 | var name_0='colnm'; 76 | 77 | var cursel_0=1; 78 | 79 | var links_len,iIntervalId; 80 | 81 | onload=function(){ 82 | 83 | var links = document.getElementById("tab1").getElementsByTagName('li') 84 | var links = document.getElementById("tab2").getElementsByTagName('dd') 85 | var links = document.getElementById("tab3").getElementsByTagName('dd') 86 | /*var links = document.getElementById("tab4").getElementsByTagName('dd')*/ 87 | var links = document.getElementById("tab5").getElementsByTagName('dd') 88 | var links = document.getElementById("tab6").getElementsByTagName('dd') 89 | 90 | links_len=links.length; 91 | 92 | for(var i=0; i result =null; 58 | if (request.getParameter("sort") != null) { 59 | String str = request.getParameter("sort"); 60 | String sort = new String(str.getBytes("iso8859-1"), "UTF-8"); 61 | request.setAttribute("lastsort", sort); 62 | // 调用service 获取查询结果 63 | if (sort.equals("按价格排序")) { 64 | result = sortService.SortByPrice(searchModel, pageNum, pageSize); 65 | System.out.println("按价格排序"); 66 | }else{ 67 | result = sortService.SortByHot(searchModel, pageNum, pageSize); 68 | System.out.println("按人气排序"); 69 | } 70 | } 71 | 72 | // 返回结果到页面 73 | request.setAttribute("result", result); 74 | request.setAttribute("itemType", type); 75 | request.getRequestDispatcher("/ShowSort.jsp").forward(request, response); 76 | 77 | } 78 | 79 | public void doPost(HttpServletRequest request, HttpServletResponse response) 80 | throws ServletException, IOException { 81 | this.doPost(request, response); 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /WebRoot/css/show.css: -------------------------------------------------------------------------------- 1 | @CHARSET "UTF-8"; 2 | .base{ 3 | position: relative; 4 | width:1000px; 5 | border: 1px solid #e6e6e6; 6 | left:50%; 7 | height: 300px; 8 | margin-left: -500px;} 9 | .base_left{ 10 | position: absolute; 11 | width:70px; 12 | height:300px; 13 | text-align: center; 14 | cursor: pointer;} 15 | .jiantou_left{ 16 | position: absolute; 17 | padding:0px; 18 | top: 50%; 19 | margin-top: -40px; 20 | left:9px; 21 | width:50px; 22 | height:80px; 23 | display: block; 24 | background: url("slider/slider.png") no-repeat 0 0; 25 | background-position: 4px -82px;} 26 | .base_right{ 27 | position: absolute; 28 | width:68px; 29 | height:300px; 30 | text-align: center; 31 | right:0px; 32 | cursor: pointer;} 33 | .jiantou_right{ 34 | position: absolute; 35 | left:0px; 36 | top: 50%; 37 | margin-top: -40px; 38 | left:9px; 39 | width:50px; 40 | height:80px; 41 | display: block; 42 | background: url("slider/slider.png") no-repeat 0 0; 43 | background-position: 5px 5px;} 44 | .content{ 45 | height: 300px; 46 | width: 860px; 47 | position: absolute; 48 | border:1px solid #e6e6e6; 49 | left:70px; 50 | background: url(photos_file/3.jpg) no-repeat; 51 | background-position: 50%;background-size: contain;} 52 | .toggle{ 53 | position: absolute; 54 | top: 300px; 55 | width: 100%; 56 | height: 30px; 57 | background: #fafafa; 58 | line-height: 30px; 59 | border-top: 1px solid #e6e6e6;} 60 | .toggle .list{ 61 | font-size: 14px; 62 | color: #666; 63 | width: 98px; 64 | cursor: pointer; 65 | background: white;} 66 | 67 | .toggle .list span{ 68 | display: block; 69 | position: absolute; 70 | left: 66px; 71 | top: 3px; 72 | width: 19px; 73 | height: 19px; 74 | background: url("slider/list.png") no-repeat 0 0; 75 | background-position: -16px -58px;} 76 | .bottle{ 77 | position: absolute; 78 | width:100%; 79 | top:300px; 80 | border:1px solid #e6e6e6; 81 | overflow: hidden; 82 | height:0px;} 83 | .bottle ul{ 84 | margin: 0px; 85 | position: absolute; 86 | height:100px; 87 | padding:0px; 88 | display:flex; 89 | width:10000px;} 90 | #list_shot{ 91 | height:300px; 92 | width:880px; 93 | position: absolute; 94 | left: 59px; 95 | overflow: hidden;} 96 | .listimg{ 97 | width:50px; 98 | height: 50px; 99 | position:relative; 100 | overflow: hidden; 101 | } 102 | .bottle .l{ 103 | display: block; 104 | position: absolute; 105 | left: 13px; 106 | top: 41px; 107 | width: 19px; 108 | height: 19px; 109 | background: url("slider/slider.png") no-repeat 0 0; 110 | background-position: -22px -205px; 111 | cursor: pointer;} 112 | .bottle .r{ 113 | display: block; 114 | position: absolute; 115 | eft: 969px; 116 | top: 41px; 117 | width: 19px; 118 | height: 19px; 119 | background: url("slider/slider.png") no-repeat 0 0; 120 | background-position: 6px -205px;cursor: pointer;} 121 | .bottle ul li{ 122 | text-decoration: none; 123 | float: left; 124 | height:100px; 125 | margin: 0px 5px; 126 | position: relative;left:0px;transition: left 0.5s;border:1px solid #e6e6e6;cursor: pointer;} 127 | .bottle ul li:hover {border:1px solid red;} -------------------------------------------------------------------------------- /src/model/Items.java: -------------------------------------------------------------------------------- 1 | package model; 2 | 3 | 4 | import java.util.Map; 5 | 6 | 7 | public class Items { 8 | private int id;//编号 9 | private String image;//图片地址 10 | private String name;//名称 11 | private String discription;//描述 12 | private int price;//价格 13 | private String contact;//联系方式 14 | private int hot;//商品热度 15 | private String type;//商品类型 16 | public String getType() { 17 | return type; 18 | } 19 | public void setType(String type) { 20 | this.type = type; 21 | } 22 | public Items(int id,String name , int price , int number){ 23 | this.id = id; 24 | this.name = name; 25 | this.price = price; 26 | this.number = number; 27 | } 28 | public Items(int id, String image, String name, String discription, 29 | int price, String contact, int hot, int number) { 30 | super(); 31 | this.id = id; 32 | this.image = image; 33 | this.name = name; 34 | this.discription = discription; 35 | this.price = price; 36 | this.contact = contact; 37 | this.hot = hot; 38 | this.number = number; 39 | } 40 | private int number; 41 | public int getNumber() { 42 | return number; 43 | } 44 | public void setNumber(int number) { 45 | this.number = number; 46 | } 47 | 48 | @Override 49 | public String toString() { 50 | return "Items [id=" + id + ", image=" + image + ", name=" + name 51 | + ", discription=" + discription + ", price=" + price 52 | + ", contact=" + contact + ", hot=" + hot + ", type=" + type 53 | + ", number=" + number + "]"; 54 | } 55 | public Items(Map map){ 56 | this.id = (Integer) map.get("id"); 57 | this.name= (String)map.get("name"); 58 | this.image = (String)map.get("image"); 59 | this.discription = (String) map.get("discription"); 60 | this.price = (Integer) map.get("price"); 61 | this.contact = (String)map.get("contact"); 62 | this.hot = (Integer)map.get("hot"); 63 | } 64 | public Items() { 65 | super(); 66 | } 67 | 68 | public Items(String image, String name, String discription, int price, 69 | String contact,int hot) { 70 | super(); 71 | this.image = image; 72 | this.name = name; 73 | this.discription = discription; 74 | this.price = price; 75 | this.contact = contact; 76 | this.hot = hot; 77 | } 78 | public Items(int id, String image, String name, String discription, 79 | int price, String contact,int hot) { 80 | super(); 81 | this.id = id; 82 | this.image = image; 83 | this.name = name; 84 | this.discription = discription; 85 | this.price = price; 86 | this.contact = contact; 87 | this.hot = hot; 88 | } 89 | public int getHot() { 90 | return hot; 91 | } 92 | public void setHot(int hot) { 93 | this.hot = hot; 94 | } 95 | public int getId() { 96 | return id; 97 | } 98 | public void setId(int id) { 99 | this.id = id; 100 | } 101 | public String getImage() { 102 | return image; 103 | } 104 | public void setImage(String image) { 105 | this.image = image; 106 | } 107 | public String getName() { 108 | return name; 109 | } 110 | public void setName(String name) { 111 | this.name = name; 112 | } 113 | public String getDiscription() { 114 | return discription; 115 | } 116 | public void setDiscription(String discription) { 117 | this.discription = discription; 118 | } 119 | public int getPrice() { 120 | return price; 121 | } 122 | public void setPrice(int price) { 123 | this.price = price; 124 | } 125 | public String getContact() { 126 | return contact; 127 | } 128 | public void setContact(String contact) { 129 | this.contact = contact; 130 | } 131 | 132 | 133 | } 134 | -------------------------------------------------------------------------------- /WebRoot/js/showImage.js: -------------------------------------------------------------------------------- 1 | window.onload = function () { 2 | var container1 = document.getElementById('image'); 3 | var list = document.getElementById('imagelist'); 4 | var buttons = document.getElementById('imagebuttons').getElementsByTagName('span'); 5 | var prev = document.getElementById('prev'); 6 | var next = document.getElementById('next'); 7 | var index = 1; 8 | var len = 5; 9 | var animated = false; 10 | var interval = 3000; 11 | var timer; 12 | 13 | 14 | function animate (offset) { 15 | if (offset == 0) { 16 | return; 17 | } 18 | animated = true; 19 | var time = 300; 20 | var inteval = 10; 21 | var speed = offset/(time/inteval); 22 | var left = parseInt(list.style.left) + offset; 23 | 24 | var go = function (){ 25 | if ( (speed > 0 && parseInt(list.style.left) < left) || (speed < 0 && parseInt(list.style.left) > left)) { 26 | list.style.left = parseInt(list.style.left) + speed + 'px'; 27 | setTimeout(go, inteval); 28 | } 29 | else { 30 | list.style.left = left + 'px'; 31 | if(left>-200){ 32 | list.style.left = -800 * len + 'px'; 33 | } 34 | if(left<(-800 * len)) { 35 | list.style.left = '-800px'; 36 | } 37 | animated = false; 38 | } 39 | } 40 | go(); 41 | } 42 | 43 | function showButton() { 44 | for (var i = 0; i < buttons.length ; i++) { 45 | if( buttons[i].className == 'on'){ 46 | buttons[i].className = ''; 47 | break; 48 | } 49 | } 50 | buttons[index - 1].className = 'on'; 51 | } 52 | 53 | function play() { 54 | timer = setTimeout(function () { 55 | next.onclick(); 56 | play(); 57 | }, interval); 58 | } 59 | function stop() { 60 | clearTimeout(timer); 61 | } 62 | 63 | next.onclick = function () { 64 | if (animated) { 65 | return; 66 | } 67 | if (index == 5) { 68 | index = 1; 69 | } 70 | else { 71 | index += 1; 72 | } 73 | animate(-800); 74 | showButton(); 75 | } 76 | prev.onclick = function () { 77 | if (animated) { 78 | return; 79 | } 80 | if (index == 1) { 81 | index = 5; 82 | } 83 | else { 84 | index -= 1; 85 | } 86 | animate(800); 87 | showButton(); 88 | } 89 | 90 | for (var i = 0; i < buttons.length; i++) { 91 | buttons[i].onclick = function () { 92 | if (animated) { 93 | return; 94 | } 95 | if(this.className == 'on') { 96 | return; 97 | } 98 | var myIndex = parseInt(this.getAttribute('index')); 99 | var offset = -800 * (myIndex - index); 100 | 101 | animate(offset); 102 | index = myIndex; 103 | showButton(); 104 | } 105 | } 106 | 107 | container1.onmouseover = stop; 108 | container1.onmouseout = play; 109 | 110 | play(); 111 | 112 | } -------------------------------------------------------------------------------- /WebRoot/Login.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 2 | <% 3 | String path = request.getContextPath(); 4 | String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 5 | %> 6 | 7 | 8 | 9 | 10 | 11 | 12 | 登陆页面 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 66 | 67 | 78 | 79 | 80 |
81 |
82 |
83 | 注册新用户 84 | 85 |
86 | 87 | 88 |
89 | 91 |
92 |
93 | 94 | 95 |
96 |
and
97 |
98 | 99 | 100 | 101 | 102 |   验证码 103 | 看不清楚
104 |

105 | 106 |
107 |
108 | 109 | 110 | 111 | 112 |
113 |
or
114 |

用户登录

115 |
116 | 117 | 118 | 119 |
120 | 121 |
122 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /WebRoot/WEB-INF/jsp/front/buy.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"%> 2 | <%@ page import="model.Items"%> 3 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 4 | <%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 5 | <% 6 | String path = request.getContextPath(); 7 | String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 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 | 37 | 38 |
39 | 66 |
67 | 68 | 75 | 76 |
77 |
78 |
79 | 82 |
83 | 84 |
85 | 86 | 87 |
88 |
89 | <% Items item = (Items)request.getAttribute("item"); %> 90 |
91 | camera 92 |
93 | 94 |

商品信息

95 |
96 |

商品名:<%=item.getName() %>

97 |

价格:<%=item.getPrice() %>

98 |

商品描述:<%=item.getDiscription() %>

99 |

联系方式:<%=item.getContact() %>

100 |
101 |
102 |
103 | 104 | 105 |
106 | 107 |
108 | 109 |
110 | 111 |
112 | 113 | 114 | -------------------------------------------------------------------------------- /src/servlet/addItemServlet.java: -------------------------------------------------------------------------------- 1 | package servlet; 2 | 3 | import java.io.File; 4 | import java.io.FileOutputStream; 5 | import java.io.IOException; 6 | import java.io.InputStream; 7 | import java.util.List; 8 | import javax.servlet.ServletException; 9 | import javax.servlet.http.HttpServlet; 10 | import javax.servlet.http.HttpServletRequest; 11 | import javax.servlet.http.HttpServletResponse; 12 | import model.Items; 13 | import org.apache.commons.fileupload.FileItem; 14 | import org.apache.commons.fileupload.disk.DiskFileItemFactory; 15 | import org.apache.commons.fileupload.servlet.ServletFileUpload; 16 | 17 | import service.ItemsService; 18 | import service.ItemsServiceImpl; 19 | 20 | 21 | public class addItemServlet extends HttpServlet { 22 | 23 | private static final long serialVersionUID = 2571998268987032737L; 24 | private ItemsService itemsService = new ItemsServiceImpl(); 25 | 26 | public void doGet(HttpServletRequest request, HttpServletResponse response) 27 | throws ServletException, IOException { 28 | //统一字符集 29 | request.setCharacterEncoding("UTF-8"); 30 | response.setCharacterEncoding("UTF-8"); 31 | // 得到上传文件的保存目录,将上传的文件存放于WEB-INF目录下,不允许外界直接访问,保证上传文件的安全 32 | String savePath = this.getServletContext().getRealPath("/upload"); 33 | 34 | File file = new File(savePath); 35 | 36 | //用于添加商品信息的items 37 | Items additem = new Items(); 38 | 39 | //上传的图片保存在服务器 upload的文件夹下 图片路径为:upload/imagefilename 40 | StringBuffer imageStr = new StringBuffer(); 41 | 42 | // 判断上传文件的保存目录是否存在 43 | if (!file.exists() && !file.isDirectory()) { 44 | // 创建目录 45 | file.mkdir(); 46 | } 47 | try { 48 | // 使用Apache文件上传组件处理文件上传步骤: 49 | // 1、创建一个DiskFileItemFactory工厂 50 | DiskFileItemFactory factory = new DiskFileItemFactory(); 51 | // 2、创建一个文件上传解析器 52 | ServletFileUpload upload = new ServletFileUpload(factory); 53 | // 解决上传文件名的中文乱码 54 | upload.setHeaderEncoding("UTF-8"); 55 | // 3、判断提交上来的数据是否是上传表单的数据 56 | if (!ServletFileUpload.isMultipartContent(request)) { 57 | // 按照传统方式获取数据 58 | return; 59 | } 60 | // 4、使用ServletFileUpload解析器解析上传数据,解析结果返回的是一个List集合,每一个FileItem对应一个Form表单的输入项 61 | List list = upload.parseRequest(request); 62 | // 表单中对应的属性为 name , image , discription , price , contact 63 | 64 | //添加name 65 | FileItem item0 = list.get(1); 66 | String value0 = item0.getString("UTF-8"); 67 | additem.setName(value0); 68 | 69 | //添加discription 70 | FileItem item2 = list.get(3); 71 | String value2 = item2.getString("UTF-8"); 72 | additem.setDiscription(value2); 73 | 74 | //添加price 75 | FileItem item3 = list.get(2); 76 | String value3 = item3.getString("UTF-8"); 77 | additem.setPrice(Integer.parseInt(value3)); 78 | 79 | //添加contact 80 | FileItem item4 = list.get(4); 81 | String value4 = item4.getString("UTF-8"); 82 | additem.setContact(value4); 83 | 84 | //添加type 85 | FileItem item5 = list.get(5); 86 | String value5 = item5.getString("UTF-8"); 87 | String type; 88 | switch (Integer.parseInt(value5)) { 89 | case 1: type = "数码产品";break; 90 | case 2: type = "图书教材";break; 91 | case 3: type = "美妆服饰";break; 92 | case 4: type = "生活其他";break; 93 | default: 94 | type = "数码产品"; 95 | break; 96 | } 97 | additem.setType(type); 98 | // 如果fileitem中封装的是上传文件 99 | // 得到上传的文件名称,这里是图片名称 100 | FileItem item = list.get(0); 101 | String filename = item.getName(); 102 | 103 | 104 | // 注意:不同的浏览器提交的文件名是不一样的,有些浏览器提交上来的文件名是带有路径的,如: 105 | // c:\a\b\1.txt,而有些只是单纯的文件名,如:1.txt 106 | // 处理获取到的上传文件的文件名的路径部分,只保留文件名部分 107 | filename = filename.substring(filename.lastIndexOf("\\") + 1); 108 | imageStr.append(filename); 109 | // 获取item中的上传文件的输入流 110 | InputStream in = item.getInputStream(); 111 | // 创建一个文件输出流 112 | FileOutputStream out = new FileOutputStream(savePath + "\\" 113 | + filename); 114 | // 创建一个缓冲区 115 | byte buffer[] = new byte[1024]; 116 | // 判断输入流中的数据是否已经读完的标识 117 | int len = 0; 118 | // 循环将输入流读入到缓冲区当中,(len=in.read(buffer))>0就表示in里面还有数据 119 | while ((len = in.read(buffer)) > 0) { 120 | // 使用FileOutputStream输出流将缓冲区的数据写入到指定的目录(savePath + "\\" + 121 | // filename)当中 122 | out.write(buffer, 0, len); 123 | } 124 | // 关闭输入流 125 | in.close(); 126 | // 关闭输出流 127 | out.close(); 128 | // 删除处理文件上传时生成的临时文件 129 | item.delete(); 130 | 131 | } catch (Exception e) { 132 | e.printStackTrace(); 133 | } 134 | 135 | //添加image(图片路径) 136 | additem.setImage(imageStr.toString()); 137 | System.out.println(additem.toString()); 138 | //调用/service 获取添加结果 139 | itemsService.addItem(additem); 140 | System.out.println("添加商品:"+additem.toString()); 141 | 142 | //将结果返回页面,跳转~ 143 | response.sendRedirect(request.getContextPath()+"/HomePage.jsp"); 144 | } 145 | 146 | public void doPost(HttpServletRequest request, HttpServletResponse response) 147 | throws ServletException, IOException { 148 | this.doGet(request, response); 149 | } 150 | } -------------------------------------------------------------------------------- /src/util/JdbcUtil.java: -------------------------------------------------------------------------------- 1 | package util; 2 | 3 | import java.io.InputStream; 4 | 5 | 6 | import java.sql.Connection; 7 | import java.sql.DriverManager; 8 | import java.sql.PreparedStatement; 9 | import java.sql.ResultSet; 10 | import java.sql.ResultSetMetaData; 11 | import java.sql.SQLException; 12 | import java.util.ArrayList; 13 | import java.util.HashMap; 14 | import java.util.List; 15 | import java.util.Map; 16 | import java.util.Properties; 17 | 18 | 19 | 20 | 21 | public class JdbcUtil { 22 | 23 | // 表示定义数据库的用户名 24 | private static String USERNAME ; 25 | 26 | // 定义数据库的密码 27 | private static String PASSWORD; 28 | 29 | // 定义数据库的驱动信息 30 | private static String DRIVER; 31 | 32 | // 定义访问数据库的地址 33 | private static String URL; 34 | 35 | // 定义数据库的链接 36 | private Connection connection; 37 | 38 | // 定义sql语句的执行对象 39 | private PreparedStatement pstmt; 40 | 41 | // 定义查询返回的结果集合 42 | private ResultSet resultSet; 43 | 44 | static{ 45 | //加载数据库配置信息,并给相关的属性赋值 46 | loadConfig(); 47 | } 48 | 49 | /** 50 | * 加载数据库配置信息,并给相关的属性赋值 51 | */ 52 | public static void loadConfig() { 53 | try { 54 | InputStream inStream = JdbcUtil.class 55 | .getResourceAsStream("/jdbc.properties"); 56 | Properties prop = new Properties(); 57 | prop.load(inStream); 58 | USERNAME = prop.getProperty("jdbc.username"); 59 | PASSWORD = prop.getProperty("jdbc.password"); 60 | DRIVER= prop.getProperty("jdbc.driver"); 61 | URL = prop.getProperty("jdbc.url"); 62 | } catch (Exception e) { 63 | throw new RuntimeException("读取数据库配置文件异常!", e); 64 | } 65 | } 66 | 67 | public JdbcUtil() { 68 | 69 | } 70 | 71 | /** 72 | * 获取数据库连接 73 | * 74 | * @return 数据库连接 75 | */ 76 | public Connection getConnection() { 77 | try { 78 | Class.forName(DRIVER); // 注册驱动 79 | connection = DriverManager.getConnection(URL, USERNAME, PASSWORD); // 获取连接 80 | } catch (Exception e) { 81 | throw new RuntimeException("get connection error!", e); 82 | } 83 | return connection; 84 | } 85 | 86 | /** 87 | * 执行更新操作 88 | * 89 | * @param sql 90 | * sql语句 91 | * @param params 92 | * 执行参数 93 | * @return 执行结果 94 | * @throws SQLException 95 | */ 96 | public boolean updateByPreparedStatement(String sql, List params) 97 | throws SQLException { 98 | boolean flag = false; 99 | int result = -1;// 表示当用户执行添加删除和修改的时候所影响数据库的行数 100 | pstmt = connection.prepareStatement(sql); 101 | int index = 1; 102 | // 填充sql语句中的占位符 103 | if (params != null && !params.isEmpty()) { 104 | for (int i = 0; i < params.size(); i++) { 105 | pstmt.setObject(index++, params.get(i)); 106 | } 107 | } 108 | result = pstmt.executeUpdate(); 109 | flag = result > 0 ? true : false; 110 | return flag; 111 | } 112 | 113 | /** 114 | * 执行查询操作 115 | * 116 | * @param sql 117 | * sql语句 118 | * @param params 119 | * 执行参数 120 | * @return 121 | * @throws SQLException 122 | */ 123 | public List> findResult(String sql, List params) 124 | throws SQLException { 125 | List> list = new ArrayList>(); 126 | int index = 1; 127 | pstmt = connection.prepareStatement(sql); 128 | if (params != null && !params.isEmpty()) { 129 | for (int i = 0; i < params.size(); i++) { 130 | pstmt.setObject(index++, params.get(i)); 131 | } 132 | } 133 | resultSet = pstmt.executeQuery(); 134 | ResultSetMetaData metaData = resultSet.getMetaData(); 135 | int cols_len = metaData.getColumnCount(); 136 | while (resultSet.next()) { 137 | Map map = new HashMap(); 138 | for (int i = 0; i < cols_len; i++) { 139 | String cols_name = metaData.getColumnName(i + 1); 140 | Object cols_value = resultSet.getObject(cols_name); 141 | if (cols_value == null) { 142 | cols_value = ""; 143 | } 144 | map.put(cols_name, cols_value); 145 | } 146 | list.add(map); 147 | } 148 | return list; 149 | } 150 | 151 | /** 152 | * 释放资源 153 | */ 154 | public void releaseConn() { 155 | if (resultSet != null) { 156 | try { 157 | resultSet.close(); 158 | } catch (SQLException e) { 159 | e.printStackTrace(); 160 | } 161 | } 162 | if (pstmt != null) { 163 | try { 164 | pstmt.close(); 165 | } catch (SQLException e) { 166 | e.printStackTrace(); 167 | } 168 | } 169 | if (connection != null) { 170 | try { 171 | connection.close(); 172 | } catch (SQLException e) { 173 | e.printStackTrace(); 174 | } 175 | } 176 | } 177 | 178 | public static void main(String[] args) { 179 | JdbcUtil jdbcUtil = new JdbcUtil(); 180 | jdbcUtil.getConnection(); 181 | try { 182 | List> result = jdbcUtil.findResult( 183 | "select * from items", null); 184 | for (Map m : result) { 185 | System.out.println(m); 186 | } 187 | } catch (SQLException e) { 188 | e.printStackTrace(); 189 | } finally { 190 | jdbcUtil.releaseConn(); 191 | } 192 | } 193 | } 194 | -------------------------------------------------------------------------------- /src/dao/SortDaoImpl.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import java.sql.SQLException; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | import util.JdbcUtil; 9 | import model.Items; 10 | import model.Pager; 11 | 12 | public class SortDaoImpl implements SortDao { 13 | 14 | //根据价格对商品排序 15 | @Override 16 | public Pager SortByPrice(Items searchModel, int pageNum, int pageSize) { 17 | Pager result = null; 18 | // 存放查询参数 19 | List paramList = new ArrayList(); 20 | 21 | String name = searchModel.getName(); 22 | String type = searchModel.getType(); 23 | StringBuilder sql = new StringBuilder( 24 | "SELECT id,image,NAME,discription,price,contact,hot FROM items WHERE 1=1 "); 25 | StringBuilder countSql = new StringBuilder( 26 | "select count(id) as totalRecord from items where 1=1 "); 27 | 28 | if (name != null && !name.equals("")) { 29 | sql.append(" and name like ?"); 30 | countSql.append(" and name like ?"); 31 | paramList.add("%" + name + "%"); 32 | } 33 | if (type != null && !type.equals("")) { 34 | sql.append(" and type = ? "); 35 | countSql.append(" and type = ? "); 36 | paramList.add(type); 37 | } 38 | sql.append(" ORDER BY price "); 39 | // 起始索引 40 | int fromIndex = pageSize * (pageNum -1); 41 | 42 | // 使用limit关键字,实现分页 43 | sql.append(" limit " + fromIndex + ", " + pageSize ); 44 | 45 | // 存放所有查询出的商品对象 46 | List itemsList = new ArrayList(); 47 | JdbcUtil jdbcUtil = null; 48 | try { 49 | jdbcUtil = new JdbcUtil(); 50 | jdbcUtil.getConnection(); // 获取数据库链接 51 | 52 | // 获取总记录数 53 | List> countResult = jdbcUtil.findResult(countSql.toString(), paramList); 54 | Map countMap = countResult.get(0); 55 | int totalRecord = ((Number)countMap.get("totalRecord")).intValue(); 56 | 57 | // 获取查询的商品记录 58 | List> itemsResult = jdbcUtil.findResult(sql.toString(), paramList); 59 | if (itemsResult != null) { 60 | System.out.println("遍历商品:"); 61 | for (Map map : itemsResult) { 62 | Items s = new Items(map); 63 | itemsList.add(s); 64 | System.out.println(s); 65 | } 66 | } 67 | 68 | //获取总页数 69 | int totalPage = totalRecord / pageSize; 70 | if(totalRecord % pageSize !=0){ 71 | totalPage++; 72 | } 73 | 74 | // 组装pager对象 75 | result = new Pager(pageSize, pageNum, 76 | totalRecord, totalPage, itemsList); 77 | 78 | } catch (SQLException e) { 79 | throw new RuntimeException("查询所有数据异常!", e); 80 | } finally { 81 | if (jdbcUtil != null) { 82 | jdbcUtil.releaseConn(); // 一定要释放资源 83 | } 84 | } 85 | return result; 86 | } 87 | 88 | //根据人气对商品排序 89 | @Override 90 | public Pager SortByHot(Items searchModel, int pageNum, int pageSize) { 91 | Pager result = null; 92 | // 存放查询参数 93 | List paramList = new ArrayList(); 94 | 95 | String name = searchModel.getName(); 96 | String type = searchModel.getType(); 97 | StringBuilder sql = new StringBuilder( 98 | "SELECT id,image,NAME,discription,price,contact,hot FROM items WHERE 1=1 "); 99 | StringBuilder countSql = new StringBuilder( 100 | "select count(id) as totalRecord from items where 1=1 "); 101 | 102 | if (name != null && !name.equals("")) { 103 | sql.append(" and name like ?"); 104 | countSql.append(" and name like ?"); 105 | paramList.add("%" + name + "%"); 106 | } 107 | if (type != null && !type.equals("")) { 108 | sql.append(" and type = ? "); 109 | countSql.append(" and type = ? "); 110 | paramList.add(type); 111 | } 112 | sql.append(" ORDER BY hot desc "); 113 | // 起始索引 114 | int fromIndex = pageSize * (pageNum -1); 115 | 116 | // 使用limit关键字,实现分页 117 | sql.append(" limit " + fromIndex + ", " + pageSize ); 118 | 119 | // 存放所有查询出的商品对象 120 | List itemsList = new ArrayList(); 121 | JdbcUtil jdbcUtil = null; 122 | try { 123 | jdbcUtil = new JdbcUtil(); 124 | jdbcUtil.getConnection(); // 获取数据库链接 125 | 126 | // 获取总记录数 127 | List> countResult = jdbcUtil.findResult(countSql.toString(), paramList); 128 | Map countMap = countResult.get(0); 129 | int totalRecord = ((Number)countMap.get("totalRecord")).intValue(); 130 | 131 | // 获取查询的商品记录 132 | List> itemsResult = jdbcUtil.findResult(sql.toString(), paramList); 133 | if (itemsResult != null) { 134 | System.out.println("遍历商品:"); 135 | for (Map map : itemsResult) { 136 | Items s = new Items(map); 137 | itemsList.add(s); 138 | System.out.println(s); 139 | } 140 | } 141 | 142 | //获取总页数 143 | int totalPage = totalRecord / pageSize; 144 | if(totalRecord % pageSize !=0){ 145 | totalPage++; 146 | } 147 | 148 | // 组装pager对象 149 | result = new Pager(pageSize, pageNum, 150 | totalRecord, totalPage, itemsList); 151 | 152 | } catch (SQLException e) { 153 | throw new RuntimeException("查询所有数据异常!", e); 154 | } finally { 155 | if (jdbcUtil != null) { 156 | jdbcUtil.releaseConn(); // 一定要释放资源 157 | } 158 | } 159 | return result; 160 | } 161 | 162 | } 163 | -------------------------------------------------------------------------------- /WebRoot/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | HomePage.jsp 9 | 10 | 11 | 12 | 13 | LoginFilter 14 | filter.LoginFilter 15 | 16 | noLoginPaths 17 | LoginServlet;ImageServlet;registerServlet;LimitItemsServlet;LimitByTypeServlet;SortItemsServlet; 18 | 19 | 20 | 21 | 22 | LoginFilter 23 | /servlet/* 24 | 25 | 26 | 27 | 28 | LoginServlet 29 | servlet.LoginServlet 30 | 31 | 32 | LoginServlet 33 | /servlet/LoginServlet 34 | 35 | 36 | 37 | 38 | LimitItemsServlet 39 | servlet.LimitItemsServlet 40 | 41 | 42 | LimitItemsServlet 43 | /servlet/LimitItemsServlet 44 | 45 | 46 | 47 | 48 | registerServlet 49 | servlet.registerServlet 50 | 51 | 52 | registerServlet 53 | /servlet/registerServlet 54 | 55 | 56 | 57 | 58 | ImageServlet 59 | servlet.ImageServlet 60 | 61 | 62 | ImageServlet 63 | /servlet/ImageServlet 64 | 65 | 66 | 67 | 68 | ShowItemServlet 69 | servlet.ShowItemServlet 70 | 71 | 72 | 73 | ShowItemServlet 74 | /servlet/ShowItemServlet 75 | 76 | 77 | 78 | 79 | CarServlet 80 | servlet.CarServlet 81 | 82 | 83 | CarServlet 84 | /servlet/CarServlet 85 | 86 | 87 | 88 | 89 | ShowCarServlet 90 | servlet.ShowCarServlet 91 | 92 | 93 | ShowCarServlet 94 | /servlet/ShowCarServlet 95 | 96 | 97 | 98 | 99 | LogOut 100 | servlet.LogOut 101 | 102 | 103 | LogOut 104 | /servlet/LogOut 105 | 106 | 107 | 108 | 109 | BuyServlet 110 | servlet.BuyServlet 111 | 112 | 113 | BuyServlet 114 | /servlet/BuyServlet 115 | 116 | 117 | 118 | 119 | addItemServlet 120 | servlet.addItemServlet 121 | 122 | 123 | addItemServlet 124 | /servlet/addItemServlet 125 | 126 | 127 | 128 | 129 | LimitByTypeServlet 130 | servlet.LimitByTypeServlet 131 | 132 | 133 | LimitByTypeServlet 134 | /servlet/LimitByTypeServlet 135 | 136 | 137 | 138 | 139 | deleteCarServlet 140 | servlet.deleteCarServlet 141 | 142 | 143 | deleteCarServlet 144 | /servlet/deleteCarServlet 145 | 146 | 147 | 148 | SortItemsServlet 149 | servlet.SortItemsServlet 150 | 151 | 152 | SortItemsServlet 153 | /servlet/SortItemsServlet 154 | 155 | 156 | 157 | -------------------------------------------------------------------------------- /WebRoot/css/Login.css: -------------------------------------------------------------------------------- 1 | * 2 | { 3 | margin:0px; 4 | padding:0px; 5 | } 6 | 7 | body{ 8 | background:#222526; 9 | position:relative; 10 | padding:20px; 11 | font-family:verdana; 12 | } 13 | #loginform 14 | { 15 | width:550px; 16 | height:auto; 17 | position:relative; 18 | top:50px; 19 | left:400px; 20 | /*margin:0 auto;*/ 21 | } 22 | 23 | input 24 | { 25 | display:block; 26 | margin:0px auto 15px; 27 | border-radius:5px; 28 | background: #333333; 29 | width:85%; 30 | padding:12px 20px 12px 10px; 31 | border:none; 32 | color:#929999; 33 | box-shadow:inset 0px 1px 5px #272727; 34 | font-size:0.8em; 35 | -webkit-transition:0.5s ease; 36 | -moz-transition:0.5s ease; 37 | -o-transition:0.5s ease; 38 | -ms-transition:0.5s ease; 39 | transition:0.5s ease; 40 | } 41 | 42 | input:focus 43 | { 44 | -webkit-transition:0.5s ease; 45 | -moz-transition:0.5s ease; 46 | -o-transition:0.5s ease; 47 | -ms-transition:0.5s ease; 48 | transition:0.5s ease; 49 | box-shadow: 0px 0px 5px 1px #161718; 50 | } 51 | 52 | button 53 | { 54 | background: #ff5f32; 55 | border-radius:50%; 56 | border:10px solid #222526; 57 | font-size:0.9em; 58 | color:#fff; 59 | font-weight:bold; 60 | cursor:pointer; 61 | width:85px; 62 | height:85px; 63 | position:absolute; 64 | right: -42px; 65 | top: 54px; 66 | text-align:center; 67 | -webkit-transition:0.5s ease; 68 | -moz-transition:0.5s ease; 69 | -o-transition:0.5s ease; 70 | -ms-transition:0.5s ease; 71 | transition:0.5s ease; 72 | } 73 | 74 | #newbutton{ 75 | position:absolute; 76 | right:50px; 77 | top:270px; 78 | } 79 | button:hover 80 | { 81 | background:#222526; 82 | border-color:#ff5f32; 83 | -webkit-transition:0.5s ease; 84 | -moz-transition:0.5s ease; 85 | -o-transition:0.5s ease; 86 | -ms-transition:0.5s ease; 87 | transition:0.5s ease; 88 | } 89 | 90 | button i 91 | { 92 | font-size:20px; 93 | -webkit-transition:0.5s ease; 94 | -moz-transition:0.5s ease; 95 | -o-transition:0.5s ease; 96 | -ms-transition:0.5s ease; 97 | transition:0.5s ease; 98 | } 99 | 100 | button:hover i 101 | { 102 | color:#ff5f32; 103 | -webkit-transition:0.5s ease; 104 | -moz-transition:0.5s ease; 105 | -o-transition:0.5s ease; 106 | -ms-transition:0.5s ease; 107 | transition:0.5s ease; 108 | } 109 | 110 | *:focus{outline:none;} 111 | ::-webkit-input-placeholder { 112 | color:#929999; 113 | } 114 | 115 | :-moz-placeholder { /* Firefox 18- */ 116 | color:#929999; 117 | } 118 | 119 | ::-moz-placeholder { /* Firefox 19+ */ 120 | color:#929999; 121 | } 122 | 123 | :-ms-input-placeholder { 124 | color:#929999; 125 | } 126 | 127 | h1 128 | { 129 | text-align:center; 130 | color:#fff; 131 | font-size:13px; 132 | padding:12px 0px; 133 | } 134 | 135 | #note 136 | { 137 | color:#88887a; 138 | font-size: 0.8em; 139 | text-align:left; 140 | padding-left:5px; 141 | } 142 | 143 | #facebook 144 | { 145 | text-align:center; 146 | float:left; 147 | background:#365195; 148 | padding:35px 10px 20px 10px; 149 | width:170px; 150 | height:135px; 151 | border-radius:3px; 152 | /*cursor:pointer;*/ 153 | box-shadow: 0px 0px 10px 2px #161718; 154 | margin-right:10px; 155 | -webkit-transition:0.5s ease; 156 | -moz-transition:0.5s ease; 157 | -o-transition:0.5s ease; 158 | -ms-transition:0.5s ease; 159 | transition:0.5s ease; 160 | } 161 | 162 | /*#facebook:hover 163 | { 164 | box-shadow: 0px 0px 0px 0px #161718; 165 | -webkit-transition:0.5s ease; 166 | -moz-transition:0.5s ease; 167 | -o-transition:0.5s ease; 168 | -ms-transition:0.5s ease; 169 | transition:0.5s ease; 170 | }*/ 171 | 172 | .fa-facebook 173 | { 174 | color:#fff; 175 | font-size:7em; 176 | display:block; 177 | } 178 | 179 | a 180 | { 181 | color:#88887a; 182 | text-decoration:none; 183 | -webkit-transition:0.5s ease; 184 | -moz-transition:0.5s ease; 185 | -o-transition:0.5s ease; 186 | -ms-transition:0.5s ease; 187 | transition:0.5s ease; 188 | } 189 | 190 | a:hover 191 | { 192 | color:#fff; 193 | margin-left:5px; 194 | -webkit-transition:0.5s ease; 195 | -moz-transition:0.5s ease; 196 | -o-transition:0.5s ease; 197 | -ms-transition:0.5s ease; 198 | transition:0.5s ease; 199 | } 200 | 201 | #mainlogin 202 | { 203 | float:left; 204 | width:250px; 205 | height:170px; 206 | padding:10px 15px; 207 | position:relative; 208 | top:50px; 209 | left:210px; 210 | background:#555555; 211 | border-radius:3px; 212 | } 213 | 214 | #connect 215 | { 216 | font-weight: bold; 217 | color: #fff; 218 | font-size: 13px; 219 | text-align: left; 220 | font-family: verdana; 221 | padding-top:10px; 222 | } 223 | 224 | #or 225 | { 226 | position:absolute; 227 | left: -25px; 228 | top: 10px; 229 | background:#222222; 230 | text-shadow:0 2px 0px #121212; 231 | color:#999999; 232 | width:40px; 233 | height:40px; 234 | text-align:center; 235 | border-radius:50%; 236 | font-weight:bold; 237 | line-height:38px; 238 | font-size: 13px; 239 | } 240 | #and{ 241 | position:absolute; 242 | left: 10px; 243 | top: -25px; 244 | background:#222222; 245 | text-shadow:0 2px 0px #121212; 246 | color:#999999; 247 | width:40px; 248 | height:40px; 249 | text-align:center; 250 | border-radius:50%; 251 | font-weight:bold; 252 | line-height:38px; 253 | font-size: 13px; 254 | } 255 | #hidelogin 256 | { 257 | float:left; 258 | width:160px; 259 | height:auto; 260 | padding:10px 15px; 261 | position:relative; 262 | top:250px; 263 | left:200px; 264 | background:#555555; 265 | border-radius:3px; 266 | visibility: hidden; 267 | } -------------------------------------------------------------------------------- /WebRoot/js/my.js: -------------------------------------------------------------------------------- 1 | $(function(){ 2 | $(".base_left").mouseover(function(){ 3 | $(this).css("background","#e6e6e6"); 4 | $(this).find("span").css("background-position","-43px -82px"); 5 | }); 6 | $(".base_left").mouseout(function(){ 7 | $(this).css("background","white"); 8 | $(this).find("span").css("background-position","4px -82px"); 9 | }); 10 | $(".base_right").mouseover(function(){ 11 | $(this).css("background","#e6e6e6"); 12 | $(this).find("span").css("background-position","-40px 5px"); 13 | }); 14 | $(".base_right").mouseout(function(){ 15 | $(this).css("background","white"); 16 | $(this).find("span").css("background-position","5px 5px"); 17 | }); 18 | $(".list").mouseover(function(){ 19 | $(this).css("background","#e6e6e6"); 20 | }); 21 | $(".list").mouseout(function(){ 22 | $(this).css("background","white"); 23 | }); 24 | 25 | var flag=0; 26 | var toggleheight=$(".list").parent().offset().top; 27 | var h=625; 28 | $(".list").click(function(){ 29 | 30 | if(flag==0){ 31 | 32 | $(this).find("span").css("background-position","3px -58px"); 33 | $(this).parent().animate({top:toggleheight-100}); 34 | $(".bottle").animate({top:h-100,height:'100px'}); 35 | $(".base_left").css("height",h-130); 36 | $(".base_right").css("height",h-130); 37 | $(".content").animate({height:h-130}); 38 | flag=1; 39 | }else{ 40 | 41 | $(this).find("span").css("background-position","-16px -58px"); 42 | $(this).parent().animate({top:toggleheight}); 43 | $(".bottle").animate({top:h,height:'0px'}); 44 | $(".base_left").css("height",h-30); 45 | $(".base_right").css("height",h-30); 46 | $(".content").animate({height:h-30}); 47 | flag=0; 48 | 49 | } 50 | }); 51 | var indexlog=3; 52 | $(".bottle ul li").mouseover(function(){ 53 | $(this).css("border","1px solid red"); 54 | $(".bottle ul li").eq(indexlog).css("border","1px solid red"); 55 | }); 56 | $(".bottle ul li").mouseout(function(){ 57 | $(this).css("border","1px solid #e6e6e6"); 58 | $(".bottle ul li").eq(indexlog).css("border","1px solid red"); 59 | }); 60 | $(".bottle ul li").click(function(){ 61 | var url=$(this).find("img").attr("src"); 62 | url="url("+url+") no-repeat"; 63 | $(".content").css("background",url).css("background-position","50%").css("background-size","contain"); 64 | indexlog=$(this).index(); 65 | var size=$(".bottle ul li").size(); 66 | if(indexlog>=3){ 67 | var left=(indexlog-3)*(-127); 68 | if((size-7)*(-127)=1){ 111 | var url=$(".bottle ul li").eq(indexlog-1).find("img").attr("src"); 112 | url="url("+url+") no-repeat"; 113 | $(".content").css("background",url).css("background-position","50%").css("background-size","contain"); 114 | var size=$(".bottle ul li").size(); 115 | if(indexlog>=4){ 116 | var left=(indexlog-4)*(-127); 117 | if((size-7)*(-127)=3){ 141 | var left=(indexlog-2)*(-127); 142 | if((size-7)*(-127) 3 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 4 | <%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> 5 | <% 6 | String path = request.getContextPath(); 7 | String basePath = request.getScheme() + "://" 8 | + request.getServerName() + ":" + request.getServerPort() 9 | + path + "/"; 10 | %> 11 | 12 | 13 | 14 | 15 | 16 | 17 | 发布商品 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |
62 | 63 | 64 |
65 |
66 | 67 | 68 | 69 |
70 |
    71 | 81 |
  • 82 |
  • 83 | 84 |
    85 |
    86 |
    87 | 89 | 93 |
    94 | 95 |
    96 |
  • 97 |
98 |
99 | 100 | 107 | 108 |
109 |
110 |
111 | 116 | 117 |
118 | 119 |
120 | 121 |
122 |
123 | 124 |
125 |

126 | 发布商品信息 127 |

128 |
129 |
132 |
    133 |
  • 上传商品图片: 135 |
  • 136 |
  • 商品名称: 138 |
  • 139 |
  • 商品价格: 141 |
  • 142 |
  • 商品描述: 144 |
  • 145 |
  • 手机号码: 147 |
  • 148 |
  • 商品类别:
  • 155 |
156 | 157 |
158 |
159 |
160 |
161 | 162 | 163 | -------------------------------------------------------------------------------- /WebRoot/css/search-form.css: -------------------------------------------------------------------------------- 1 | /* html,body {height: 100%;} */ 2 | 3 | 4 | .search-wrapper { 5 | position: relative; 6 | -webkit-transform: translate(-50%, -50%); 7 | -moz-transform: translate(-50%, -50%); 8 | transform: translate(-50%, -50%); 9 | left:700px; 10 | top:-20px; 11 | height:40px; 12 | 13 | } 14 | .search-wrapper.active {} 15 | 16 | .search-wrapper .input-holder { 17 | overflow: hidden; 18 | height: 45px; 19 | background: rgba(255,255,255,0); 20 | border-radius:6px; 21 | position: relative; 22 | width:40px; 23 | -webkit-transition: all 0.3s ease-in-out; 24 | -moz-transition: all 0.3s ease-in-out; 25 | transition: all 0.3s ease-in-out; 26 | } 27 | .search-wrapper.active .input-holder { 28 | border-radius: 50px; 29 | width:450px; 30 | background: rgba(0,0,0,0.5); 31 | -webkit-transition: all .5s cubic-bezier(0.000, 0.105, 0.035, 1.570); 32 | -moz-transition: all .5s cubic-bezier(0.000, 0.105, 0.035, 1.570); 33 | transition: all .5s cubic-bezier(0.000, 0.105, 0.035, 1.570); 34 | } 35 | 36 | .search-wrapper .input-holder .search-input { 37 | width:100%; 38 | height: 50px; 39 | padding:0px 70px 0 20px; 40 | opacity: 0; 41 | position: absolute; 42 | top:-10px; 43 | left:0px; 44 | background: transparent; 45 | -webkit-box-sizing: border-box; 46 | -moz-box-sizing: border-box; 47 | box-sizing: border-box; 48 | border:none; 49 | outline:none; 50 | font-family:"Open Sans", Arial, Verdana; 51 | font-size: 16px; 52 | font-weight: 400; 53 | color:#FFF; 54 | -webkit-transform: translate(0, 60px); 55 | -moz-transform: translate(0, 60px); 56 | transform: translate(0, 60px); 57 | -webkit-transition: all .3s cubic-bezier(0.000, 0.105, 0.035, 1.570); 58 | -moz-transition: all .3s cubic-bezier(0.000, 0.105, 0.035, 1.570); 59 | transition: all .3s cubic-bezier(0.000, 0.105, 0.035, 1.570); 60 | 61 | -webkit-transition-delay: 0.3s; 62 | -moz-transition-delay: 0.3s; 63 | transition-delay: 0.3s; 64 | } 65 | .search-wrapper.active .input-holder .search-input { 66 | opacity: 1; 67 | -webkit-transform: translate(0, 10px); 68 | -moz-transform: translate(0, 10px); 69 | transform: translate(0, 10px); 70 | } 71 | 72 | .search-wrapper .input-holder .search-icon { 73 | width:40px; 74 | height:40px; 75 | border:none; 76 | border-radius:6px; 77 | background: #FFF; 78 | padding:0px; 79 | outline:none; 80 | position: relative; 81 | z-index: 2; 82 | float:right; 83 | cursor: pointer; 84 | -webkit-transition: all 0.3s ease-in-out; 85 | -moz-transition: all 0.3s ease-in-out; 86 | transition: all 0.3s ease-in-out; 87 | } 88 | .search-wrapper.active .input-holder .search-icon { 89 | width: 40px; 90 | height:40px; 91 | margin: 0px; 92 | border-radius: 30px; 93 | } 94 | .search-wrapper .input-holder .search-icon span { 95 | width:22px; 96 | height:22px; 97 | display: inline-block; 98 | vertical-align: middle; 99 | position:relative; 100 | -webkit-transform: rotate(45deg); 101 | -moz-transform: rotate(45deg); 102 | transform: rotate(45deg); 103 | -webkit-transition: all .4s cubic-bezier(0.650, -0.600, 0.240, 1.650); 104 | -moz-transition: all .4s cubic-bezier(0.650, -0.600, 0.240, 1.650); 105 | transition: all .4s cubic-bezier(0.650, -0.600, 0.240, 1.650); 106 | 107 | } 108 | .search-wrapper.active .input-holder .search-icon span { 109 | -webkit-transform: rotate(-45deg); 110 | -moz-transform: rotate(-45deg); 111 | transform: rotate(-45deg); 112 | } 113 | .search-wrapper .input-holder .search-icon span::before, .search-wrapper .input-holder .search-icon span::after { 114 | position: absolute; 115 | content:''; 116 | } 117 | .search-wrapper .input-holder .search-icon span::before { 118 | width: 4px; 119 | height: 11px; 120 | left: 9px; 121 | top: 15px; 122 | border-radius: 2px; 123 | background: #974BE0; 124 | } 125 | .search-wrapper .input-holder .search-icon span::after { 126 | width: 14px; 127 | height: 14px; 128 | left: 0px; 129 | top: 0px; 130 | border-radius: 16px; 131 | border: 4px solid #974BE0; 132 | } 133 | 134 | .search-wrapper .close { 135 | position: absolute; 136 | z-index: 1; 137 | top:16px; 138 | right:14px; 139 | width:25px; 140 | height:25px; 141 | cursor: pointer; 142 | -webkit-transform: rotate(-180deg); 143 | -moz-transform: rotate(-180deg); 144 | transform: rotate(-180deg); 145 | -webkit-transition: all .3s cubic-bezier(0.285, -0.450, 0.935, 0.110); 146 | -moz-transition: all .3s cubic-bezier(0.285, -0.450, 0.935, 0.110); 147 | transition: all .3s cubic-bezier(0.285, -0.450, 0.935, 0.110); 148 | -webkit-transition-delay: 0.2s; 149 | -moz-transition-delay: 0.2s; 150 | transition-delay: 0.2s; 151 | } 152 | .search-wrapper.active .close { 153 | right:-50px; 154 | -webkit-transform: rotate(45deg); 155 | -moz-transform: rotate(45deg); 156 | transform: rotate(45deg); 157 | -webkit-transition: all .6s cubic-bezier(0.000, 0.105, 0.035, 1.570); 158 | -moz-transition: all .6s cubic-bezier(0.000, 0.105, 0.035, 1.570); 159 | transition: all .6s cubic-bezier(0.000, 0.105, 0.035, 1.570); 160 | -webkit-transition-delay: 0.5s; 161 | -moz-transition-delay: 0.5s; 162 | transition-delay: 0.5s; 163 | } 164 | .search-wrapper .close::before, .search-wrapper .close::after { 165 | position:absolute; 166 | content:''; 167 | background: #FFF; 168 | border-radius: 2px; 169 | } 170 | .search-wrapper .close::before { 171 | width: 5px; 172 | height: 25px; 173 | left: 10px; 174 | top: 0px; 175 | } 176 | .search-wrapper .close::after { 177 | width: 25px; 178 | height: 5px; 179 | left: 0px; 180 | top: 10px; 181 | } 182 | .search-wrapper .result-container { 183 | width: 100%; 184 | position:relative; 185 | top:20px; 186 | left:0px; 187 | text-align: center; 188 | font-family: "Open Sans", Arial, Verdana; 189 | font-size: 14px; 190 | display:none; 191 | color:#B7B7B7; 192 | } 193 | 194 | 195 | -------------------------------------------------------------------------------- /WebRoot/css/default.css: -------------------------------------------------------------------------------- 1 | @import url(http://fonts.useso.com/css?family=Raleway:200,500,700,800); 2 | @font-face { 3 | font-family: 'icomoon'; 4 | src:url('../fonts/icomoon.eot?rretjt'); 5 | src:url('../fonts/icomoon.eot?#iefixrretjt') format('embedded-opentype'), 6 | url('../fonts/icomoon.woff?rretjt') format('woff'), 7 | url('../fonts/icomoon.ttf?rretjt') format('truetype'), 8 | url('../fonts/icomoon.svg?rretjt#icomoon') format('svg'); 9 | font-weight: normal; 10 | font-style: normal; 11 | } 12 | 13 | [class^="icon-"], [class*=" icon-"] { 14 | font-family: 'icomoon'; 15 | speak: none; 16 | font-style: normal; 17 | font-weight: normal; 18 | font-variant: normal; 19 | text-transform: none; 20 | line-height: 1; 21 | 22 | /* Better Font Rendering =========== */ 23 | -webkit-font-smoothing: antialiased; 24 | -moz-osx-font-smoothing: grayscale; 25 | } 26 | 27 | body, html { font-size: 100%; padding: 0; margin: 0;} 28 | 29 | 30 | /* Clearfix hack by Nicolas Gallagher: http://nicolasgallagher.com/micro-clearfix-hack/ */ 31 | .clearfix:before, 32 | .clearfix:after { 33 | content: " "; 34 | display: table; 35 | } 36 | 37 | .clearfix:after { 38 | clear: both; 39 | } 40 | 41 | body{ 42 | color: #fff; 43 | font-weight: 500; 44 | font-size: 1.05em; 45 | font-family: "Microsoft YaHei","宋体","Segoe UI", "Lucida Grande", Helvetica, Arial,sans-serif, FreeSans, Arimo; 46 | } 47 | a{color: #2fa0ec;text-decoration: none;outline: none;} 48 | a:hover,a:focus{color:#74777b;} 49 | 50 | .htmleaf-container{ 51 | margin: 0 auto; 52 | text-align: center; 53 | overflow: hidden; 54 | } 55 | 56 | .bgcolor-1 { background: #f0efee; } 57 | .bgcolor-2 { background: #f9f9f9; } 58 | .bgcolor-3 { background: #e8e8e8; }/*light grey*/ 59 | .bgcolor-4 { background: #2f3238; color: #fff; }/*Dark grey*/ 60 | .bgcolor-5 { background: #df6659; color: #521e18; }/*pink1*/ 61 | .bgcolor-6 { background: #2fa8ec; }/*sky blue*/ 62 | .bgcolor-7 { background: #d0d6d6; }/*White tea*/ 63 | .bgcolor-8 { background: #3d4444; color: #fff; }/*Dark grey2*/ 64 | .bgcolor-9 { background: #ef3f52; color: #fff;}/*pink2*/ 65 | .bgcolor-10{ background: #64448f; color: #fff;}/*Violet*/ 66 | .bgcolor-11{ background: #3755ad; color: #fff;}/*dark blue*/ 67 | .bgcolor-12{ background: #3498DB; color: #fff;}/*light blue*/ 68 | .bgcolor-20{ background: #494A5F;color: #D5D6E2;} 69 | /* Header */ 70 | .htmleaf-header{ 71 | padding: 1em 190px 1em; 72 | letter-spacing: -1px; 73 | text-align: center; 74 | } 75 | .htmleaf-header h1 { 76 | color: #fff; 77 | font-weight: 600; 78 | font-size: 2em; 79 | line-height: 1; 80 | margin-bottom: 0; 81 | font-family: "Microsoft YaHei","宋体","Segoe UI", "Lucida Grande", Helvetica, Arial,sans-serif, FreeSans, Arimo; 82 | } 83 | .htmleaf-header h1 span { 84 | font-family: "Microsoft YaHei","宋体","Segoe UI", "Lucida Grande", Helvetica, Arial,sans-serif, FreeSans, Arimo; 85 | display: block; 86 | font-size: 60%; 87 | font-weight: 400; 88 | padding: 0.8em 0 0.5em 0; 89 | color: #fff; 90 | } 91 | /*nav*/ 92 | .htmleaf-demo a{color: #1d7db1;text-decoration: none;} 93 | .htmleaf-demo{width: 100%;padding-bottom: 1.2em;} 94 | .htmleaf-demo a{display: inline-block;margin: 0.5em;padding: 0.6em 1em;border: 3px solid #1d7db1;font-weight: 700;} 95 | .htmleaf-demo a:hover{opacity: 0.6;} 96 | .htmleaf-demo a.current{background:#1d7db1;color: #fff; } 97 | /* Top Navigation Style */ 98 | .htmleaf-links { 99 | position: relative; 100 | display: inline-block; 101 | white-space: nowrap; 102 | font-size: 1.5em; 103 | text-align: center; 104 | } 105 | 106 | .htmleaf-links::after { 107 | position: absolute; 108 | top: 0; 109 | left: 50%; 110 | margin-left: -1px; 111 | width: 2px; 112 | height: 100%; 113 | background: #dbdbdb; 114 | content: ''; 115 | -webkit-transform: rotate3d(0,0,1,22.5deg); 116 | transform: rotate3d(0,0,1,22.5deg); 117 | } 118 | 119 | .htmleaf-icon { 120 | display: inline-block; 121 | margin: 0.5em; 122 | padding: 0em 0; 123 | width: 1.5em; 124 | text-decoration: none; 125 | } 126 | 127 | .htmleaf-icon span { 128 | display: none; 129 | } 130 | 131 | .htmleaf-icon:before { 132 | margin: 0 5px; 133 | text-transform: none; 134 | font-weight: normal; 135 | font-style: normal; 136 | font-variant: normal; 137 | font-family: 'icomoon'; 138 | line-height: 1; 139 | speak: none; 140 | -webkit-font-smoothing: antialiased; 141 | } 142 | /* footer */ 143 | .htmleaf-footer{width: 100%;padding-top: 10px;} 144 | .htmleaf-small{font-size: 0.8em;} 145 | .center{text-align: center;} 146 | /****/ 147 | .related { 148 | color: #fff; 149 | background: #494A5F; 150 | text-align: center; 151 | font-size: 1.25em; 152 | padding: 0.5em 0; 153 | overflow: hidden; 154 | } 155 | 156 | .related > a { 157 | vertical-align: top; 158 | width: calc(100% - 20px); 159 | max-width: 340px; 160 | display: inline-block; 161 | text-align: center; 162 | margin: 20px 10px; 163 | padding: 25px; 164 | font-family: "Microsoft YaHei","宋体","Segoe UI", "Lucida Grande", Helvetica, Arial,sans-serif, FreeSans, Arimo; 165 | } 166 | .related a { 167 | display: inline-block; 168 | text-align: left; 169 | margin: 20px auto; 170 | padding: 10px 20px; 171 | opacity: 0.8; 172 | -webkit-transition: opacity 0.3s; 173 | transition: opacity 0.3s; 174 | -webkit-backface-visibility: hidden; 175 | } 176 | 177 | .related a:hover, 178 | .related a:active { 179 | opacity: 1; 180 | } 181 | 182 | .related a img { 183 | max-width: 100%; 184 | opacity: 0.8; 185 | border-radius: 4px; 186 | } 187 | .related a:hover img, 188 | .related a:active img { 189 | opacity: 1; 190 | } 191 | .related h3{font-family: "Microsoft YaHei", sans-serif;} 192 | .related a h3 { 193 | font-weight: 300; 194 | margin-top: 0.15em; 195 | color: #fff; 196 | } 197 | /* icomoon */ 198 | .icon-htmleaf-home-outline:before { 199 | content: "\e5000"; 200 | } 201 | 202 | .icon-htmleaf-arrow-forward-outline:before { 203 | content: "\e5001"; 204 | } 205 | 206 | @media screen and (max-width: 50em) { 207 | .htmleaf-header { 208 | padding: 3em 10% 4em; 209 | } 210 | .htmleaf-header h1 { 211 | font-size:2em; 212 | } 213 | } 214 | 215 | 216 | @media screen and (max-width: 40em) { 217 | .htmleaf-header h1 { 218 | font-size: 1.5em; 219 | } 220 | } 221 | 222 | @media screen and (max-width: 30em) { 223 | .htmleaf-header h1 { 224 | font-size:1.2em; 225 | } 226 | } -------------------------------------------------------------------------------- /src/dao/CarsDaoImpl.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import java.sql.SQLException; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | import util.JdbcUtil; 9 | 10 | 11 | import model.Items; 12 | 13 | public class CarsDaoImpl implements CarsDao { 14 | 15 | /** 16 | * 添加商品到购物车 17 | */ 18 | @Override 19 | public boolean addItemToCar(int userID, Items item ,int number) { 20 | List paramList = new ArrayList(); 21 | StringBuilder sql = new StringBuilder( 22 | "insert into cars(userID,itemID,itemPrice,itemName,itemImage,itemNumber) values(?,?,?,?,?,?)"); 23 | 24 | //填充占位符 25 | int itemID = item.getId(); 26 | int itemPrice = item.getPrice(); 27 | String itemName = item.getName(); 28 | String itemImage = item.getImage(); 29 | 30 | paramList.add(userID); 31 | paramList.add(itemID); 32 | paramList.add(itemPrice); 33 | paramList.add(itemName); 34 | paramList.add(itemImage); 35 | paramList.add(number); 36 | 37 | JdbcUtil jdbcUtil = null; 38 | try { 39 | jdbcUtil = new JdbcUtil(); 40 | jdbcUtil.getConnection(); // 获取数据库链接 41 | 42 | // 添加的商品信息 43 | boolean flag = jdbcUtil.updateByPreparedStatement(sql.toString(), paramList); 44 | if(flag==true){ 45 | System.out.println("用户:"+userID+"添加购物车:"+item.toString()+"数量"+number); 46 | } 47 | return flag; 48 | } catch (SQLException e) { 49 | throw new RuntimeException("添加购物车异常!", e); 50 | } finally { 51 | if (jdbcUtil != null) { 52 | jdbcUtil.releaseConn(); // 一定要释放资源 53 | } 54 | } 55 | } 56 | 57 | /** 58 | * 遍历购物车中的所有商品 59 | */ 60 | @Override 61 | public List ShowItemInCar(int userID) { 62 | List paramList = new ArrayList(); 63 | List resultItems = new ArrayList(); 64 | StringBuilder sql = new StringBuilder( 65 | "select itemID,itemPrice,itemName,itemImage,itemNumber from cars where userID=? "); 66 | //填充占位符 67 | paramList.add(userID); 68 | 69 | JdbcUtil jdbcUtil = null; 70 | try { 71 | jdbcUtil = new JdbcUtil(); 72 | jdbcUtil.getConnection(); // 获取数据库链接 73 | 74 | // 添加的商品信息 75 | List> itemsList = jdbcUtil.findResult(sql.toString(), paramList); 76 | System.out.println("遍历购物车:"); 77 | if (itemsList != null) { 78 | for (Map map : itemsList) { 79 | Items s = new Items(); 80 | s.setId((Integer) map.get("itemID")); 81 | s.setName((String)map.get("itemName")); 82 | s.setImage((String)map.get("itemImage")); 83 | s.setPrice((Integer)map.get("itemPrice")); 84 | s.setNumber((Integer)map.get("itemNumber")); 85 | System.out.println(s.toString()); 86 | resultItems.add(s); 87 | } 88 | } 89 | } catch (SQLException e) { 90 | throw new RuntimeException("遍历购物车异常!", e); 91 | } finally { 92 | if (jdbcUtil != null) { 93 | jdbcUtil.releaseConn(); // 一定要释放资源 94 | } 95 | } 96 | return resultItems; 97 | } 98 | 99 | //为购物车中已经存在的商品增加数量 100 | @Override 101 | public boolean updateItemInCar(int itemID, int userID, int number) { 102 | List paramList = new ArrayList(); 103 | StringBuilder sql = new StringBuilder( 104 | "update cars set itemNumber=itemNumber+? where userID=? and itemID=? "); 105 | //填充占位符 106 | paramList.add(number); 107 | paramList.add(userID); 108 | paramList.add(itemID); 109 | 110 | JdbcUtil jdbcUtil = null; 111 | try { 112 | jdbcUtil = new JdbcUtil(); 113 | jdbcUtil.getConnection(); // 获取数据库链接 114 | 115 | // 添加的商品信息 116 | boolean flag = jdbcUtil.updateByPreparedStatement(sql.toString(), paramList); 117 | if(flag==true){ 118 | System.out.println("用户:"+userID+"更新商品:"+itemID+"数量"+number); 119 | } 120 | return flag; 121 | } catch (SQLException e) { 122 | throw new RuntimeException("添加购物车异常!", e); 123 | } finally { 124 | if (jdbcUtil != null) { 125 | jdbcUtil.releaseConn(); // 一定要释放资源 126 | } 127 | } 128 | } 129 | 130 | //添加商品信息 131 | @Override 132 | public boolean addItem(Items additem) { 133 | List paramList = new ArrayList(); 134 | StringBuilder sql = new StringBuilder( 135 | "insert into items(image,name,discription,price,contact,type) values(?,?,?,?,?,?)"); 136 | 137 | String image = additem.getImage(); 138 | if (image != null && !image.equals("")) { 139 | paramList.add(image); 140 | } 141 | String name = additem.getName(); 142 | if (name != null && !name.equals("")) { 143 | paramList.add(name); 144 | } 145 | String discription = additem.getDiscription(); 146 | if (discription != null && !discription.equals("")) { 147 | paramList.add(discription); 148 | } 149 | int price = additem.getPrice(); 150 | if (price != 0) { 151 | paramList.add(price); 152 | } 153 | String contact = additem.getContact(); 154 | if (contact != null && !contact.equals("")) { 155 | paramList.add(contact); 156 | } 157 | String type = additem.getType(); 158 | if (type != null && !type.equals("")) { 159 | paramList.add(type); 160 | } 161 | 162 | JdbcUtil jdbcUtil = null; 163 | try { 164 | jdbcUtil = new JdbcUtil(); 165 | jdbcUtil.getConnection(); // 获取数据库链接 166 | 167 | // 添加的商品信息 168 | boolean flag = jdbcUtil.updateByPreparedStatement(sql.toString(), paramList); 169 | if(flag==true){ 170 | System.out.println("添加商品:"+additem.toString()); 171 | } 172 | return flag; 173 | } catch (SQLException e) { 174 | throw new RuntimeException("查询所有数据异常!", e); 175 | } finally { 176 | if (jdbcUtil != null) { 177 | jdbcUtil.releaseConn(); // 一定要释放资源 178 | } 179 | } 180 | } 181 | 182 | //从购物车移除商品,传入用户ID和商品ID组成的数组 183 | @Override 184 | public boolean deleteItems(int userID, int[] id) { 185 | List paramList = new ArrayList(); 186 | StringBuilder sql = new StringBuilder( 187 | "delete from cars where userID=? and itemID in( "); 188 | paramList.add(userID); 189 | //填充占位符 190 | for(int i = 0 ; i < id.length-1 ; i++){ 191 | sql.append("?,"); 192 | paramList.add(id[i]); 193 | } 194 | sql.append("?)"); 195 | paramList.add(id[id.length-1]); 196 | JdbcUtil jdbcUtil = null; 197 | try { 198 | jdbcUtil = new JdbcUtil(); 199 | jdbcUtil.getConnection(); // 获取数据库链接 200 | 201 | // 添加的商品信息 202 | boolean flag = jdbcUtil.updateByPreparedStatement(sql.toString(), paramList); 203 | if(flag==true){ 204 | System.out.println("用户:"+userID+"从购物车中移除商品"); 205 | } 206 | return flag; 207 | } catch (SQLException e) { 208 | throw new RuntimeException("移除购物车异常!", e); 209 | } finally { 210 | if (jdbcUtil != null) { 211 | jdbcUtil.releaseConn(); // 一定要释放资源 212 | } 213 | } 214 | } 215 | 216 | } 217 | -------------------------------------------------------------------------------- /shixun.sql: -------------------------------------------------------------------------------- 1 | /* 2 | SQLyog Ultimate v11.11 (64 bit) 3 | MySQL - 5.5.46 : Database - shixun 4 | ********************************************************************* 5 | */ 6 | 7 | /*!40101 SET NAMES utf8 */; 8 | 9 | /*!40101 SET SQL_MODE=''*/; 10 | 11 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 12 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 13 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 14 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 15 | CREATE DATABASE /*!32312 IF NOT EXISTS*/`shixun` /*!40100 DEFAULT CHARACTER SET utf8 */; 16 | 17 | USE `shixun`; 18 | 19 | /*Table structure for table `buy_items` */ 20 | 21 | DROP TABLE IF EXISTS `buy_items`; 22 | 23 | CREATE TABLE `buy_items` ( 24 | `itemID` int(10) NOT NULL, 25 | `buy_Time` varchar(20) NOT NULL, 26 | `userID` int(10) NOT NULL, 27 | `itemPrice` int(20) NOT NULL, 28 | `itemNumber` int(20) NOT NULL, 29 | `itemName` varchar(20) NOT NULL 30 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 31 | 32 | /*Data for the table `buy_items` */ 33 | 34 | insert into `buy_items`(`itemID`,`buy_Time`,`userID`,`itemPrice`,`itemNumber`,`itemName`) values (7,'2016-06-29',1,40,1,'镂空V领T恤'),(46,'2016-06-30',5,12,1,'Spring实战'); 35 | 36 | /*Table structure for table `cars` */ 37 | 38 | DROP TABLE IF EXISTS `cars`; 39 | 40 | CREATE TABLE `cars` ( 41 | `itemID` int(20) DEFAULT NULL, 42 | `userID` int(20) NOT NULL, 43 | `itemPrice` int(20) DEFAULT NULL, 44 | `itemName` varchar(20) DEFAULT NULL, 45 | `itemImage` varchar(40) DEFAULT NULL, 46 | `itemNumber` int(20) DEFAULT NULL 47 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 48 | 49 | /*Data for the table `cars` */ 50 | 51 | insert into `cars`(`itemID`,`userID`,`itemPrice`,`itemName`,`itemImage`,`itemNumber`) values (9,1,50,'欧根纱两件套连衣裙','9.jpg',1),(5,1,20,'复古大框偏光太阳镜','5.jpg',1),(52,5,10,'床上书桌','53.jpg',1),(9,5,50,'欧根纱两件套连衣裙','9.jpg',1); 52 | 53 | /*Table structure for table `items` */ 54 | 55 | DROP TABLE IF EXISTS `items`; 56 | 57 | CREATE TABLE `items` ( 58 | `id` int(10) NOT NULL AUTO_INCREMENT, 59 | `image` varchar(60) NOT NULL, 60 | `name` varchar(20) NOT NULL, 61 | `discription` varchar(40) NOT NULL, 62 | `price` int(10) NOT NULL, 63 | `contact` varchar(20) NOT NULL, 64 | `hot` int(20) DEFAULT '0', 65 | `type` varchar(10) NOT NULL, 66 | PRIMARY KEY (`id`) 67 | ) ENGINE=InnoDB AUTO_INCREMENT=61 DEFAULT CHARSET=utf8; 68 | 69 | /*Data for the table `items` */ 70 | 71 | insert into `items`(`id`,`image`,`name`,`discription`,`price`,`contact`,`hot`,`type`) values (1,'1.jpg','智能手表','很高科技',100,'152436161117',300,'数码产品'),(4,'4.jpg','防晒风衣','只穿过一次',50,'16660262095',0,'美妆服饰'),(5,'5.jpg','复古大框偏光太阳镜','女生戴着很帅气',20,'18040697018',100,'美妆服饰'),(6,'6.jpg','韩国V7素颜霜','还有很多没用',30,'19367413893',100,'美妆服饰'),(7,'7.jpg','镂空V领T恤','很好看,M码',40,'16064772951',400,'美妆服饰'),(8,'8.jpg','牛仔拼接连衣裙','穿着很漂亮',40,'16694736065',100,'美妆服饰'),(9,'9.jpg','欧根纱两件套连衣裙','材质很好',50,'16833879015',200,'美妆服饰'),(10,'10.jpg','倩碧润肤乳','很好用的牌子',20,'16833879015',0,'美妆服饰'),(11,'12.jpg','水宝宝防晒霜','很方便',20,'18763699886',0,'美妆服饰'),(12,'13.jpg','条纹A字裙','男生穿着都好看',30,'18801787792',0,'美妆服饰'),(13,'14.jpg','雅诗兰黛精华露','弹走皱纹',30,'18801787792',0,'美妆服饰'),(14,'15.jpg','依泉舒缓保湿喷雾','很保湿',20,'15045622631',0,'美妆服饰'),(15,'16.jpg','印花短裙套装','好看',100,'16482263514',0,'美妆服饰'),(16,'17.jpg','印花复古猫眼太阳镜','巨好看',30,'15065507132',0,'美妆服饰'),(17,'18.jpg','御泥坊面膜','好用',50,'15284116775',0,'美妆服饰'),(18,'19.jpg','资生堂洁面乳套装','很划算',80,'18826153956',0,'美妆服饰'),(19,'20.jpg','自然乐园芦荟胶','很健康',50,'16386820829',0,'美妆服饰'),(20,'21.jpg','字母休闲T恤','很休闲',25,'17156571390',0,'美妆服饰'),(21,'2.jpg','iPhone手机','九成新甩卖',3000,'15074048527',0,'数码产品'),(22,'3.jpg','智能手表','很高科技',100,'13386960435',0,'数码产品'),(23,'24.jpg','数码相机','和女票分手了,没有人可以拍',400,'15649747898',0,'数码产品'),(24,'25.jpg','耳机','适合运动的时候戴',30,'18932117825',0,'数码产品'),(25,'27.jpg','粉色笔记本','颜值很高的电脑',2500,'15794843550',0,'数码产品'),(26,'28.jpg','大音响','音效很棒',360,'15876119856',0,'数码产品'),(27,'29.jpg','音响','九成新',250,'15626227448',0,'数码产品'),(28,'30.jpg','国产手机','电池很耐用',600,'13741618975',0,'数码产品'),(29,'31.jpg','oppo手机','白色的很好看',1200,'13885918190',0,'数码产品'),(30,'32.jpg','iPhone10','最新的iPhone手机',250,'15941975035',0,'数码产品'),(31,'33.jpg','拍立得照相机','很方便使用',2500,'15048790637',0,'数码产品'),(32,'34.jpg','摄像机','才用了两个月',900,'13004383764',0,'数码产品'),(33,'35.jpg','粉色耳机','音效不错',25,'13796633815',0,'数码产品'),(34,'36.jpg','sony耳机','品牌耳机',380,'15705794677',0,'数码产品'),(35,'38.jpg','运动式耳机','适合跑步听',20,'13531858319',0,'数码产品'),(36,'39.jpg','智能耳机','黑科技',999,'13579858863',0,'数码产品'),(37,'ipod.jpg','lpod','很好用',60,'15659527647',0,'数码产品'),(38,'sonymp3.jpg','mp3附带耳机','人帅不要钱',1,'13440381075',0,'数码产品'),(39,'kindle.jpg','kindle','人丑就要多读书',150,'13078170543',0,'数码产品'),(40,'kindle+touch.jpg','kindle+touch','好读书,不求甚解',250,'13437488010',0,'数码产品'),(41,'CSS.jpg','CSS揭秘','从入门到放弃',20,'15762862392',0,'图书教材'),(42,'Javascript.jpg','Javascript','从入门到放弃',25,'15293345456',0,'图书教材'),(43,'Linux.jpg','Linux环境编程:从应用到内核','从入门到放弃',38,'13378296487',0,'图书教材'),(44,'Photoshop_CS6.jpg','Photoshop_CS6从入门到精通','从入门到放弃',40,'15186558335',0,'图书教材'),(45,'Python.jpg','Python学习手册','从入门到放弃',29,'15742913925',100,'图书教材'),(46,'Spring.jpg','Spring实战','从入门到放弃',12,'18834393701',100,'图书教材'),(47,'40.jpg','白夜行','变态恋童癖',30,'18871034264',100,'图书教材'),(48,'41.jpg','百年孤独','单身孤独',25,'15136017949',0,'图书教材'),(49,'50.jpg','不锈钢电热锅','毕业大甩卖',20,'13115843922',0,'生活其他'),(50,'51.jpg','充电小台灯','毕业大甩卖',10,'13334735830',0,'生活其他'),(51,'52.jpg','抽屉收纳盒','毕业大甩卖',15,'18924582414',0,'生活其他'),(52,'53.jpg','床上书桌','毕业大甩卖',10,'15309138764',100,'生活其他'),(53,'54.jpg','床上书桌','毕业大甩卖',12,'15513261405',0,'生活其他'),(54,'55.jpg','床上书桌电脑桌','毕业大甩卖',13,'13925921269',0,'生活其他'),(55,'55.jpg','自行车','毕业大甩卖',80,'15751891641',100,'生活其他'),(56,'bike05.jpg','自行车','毕业大甩卖',60,'13943139262',0,'生活其他'),(57,'56.jpg','自行车','九成新的车',100,'13199424495',0,'生活其他'),(58,'bike04.jpg','自行车','很漂亮的车',70,'15260580696',0,'生活其他'),(59,'bike10.jpg','自行车','偷来的',150,'13087549099',0,'生活其他'),(60,'bike01.jpg','自行车','室友的车',88,'15693659057',0,'生活其他'); 72 | 73 | /*Table structure for table `users` */ 74 | 75 | DROP TABLE IF EXISTS `users`; 76 | 77 | CREATE TABLE `users` ( 78 | `username` varchar(20) NOT NULL, 79 | `password` varchar(20) NOT NULL, 80 | `contact` varchar(20) DEFAULT NULL, 81 | `address` varchar(40) DEFAULT NULL, 82 | `userID` int(10) NOT NULL AUTO_INCREMENT, 83 | PRIMARY KEY (`userID`), 84 | KEY `checkUser` (`username`,`password`) 85 | ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; 86 | 87 | /*Data for the table `users` */ 88 | 89 | insert into `users`(`username`,`password`,`contact`,`address`,`userID`) values ('admin','admin','110','长沙',1),('zl','zl','15243616117','岳阳',5); 90 | 91 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 92 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 93 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 94 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 95 | -------------------------------------------------------------------------------- /WebRoot/HomePage.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" import="java.util.*" 2 | contentType="text/html; charset=utf-8"%> 3 | <%@ page import="java.util.*"%> 4 | <%@ page import="java.io.*"%> 5 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 6 | <%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> 7 | <% 8 | String path = request.getContextPath(); 9 | String basePath = request.getScheme() + "://" 10 | + request.getServerName() + ":" + request.getServerPort() 11 | + path + "/"; 12 | %> 13 | 14 | 15 | 16 | 17 | 18 | 首页 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 42 | 43 | 44 | 45 |
46 |
47 |
48 | 49 | 50 |
51 |
52 | 53 | 54 |
55 | 92 |
93 |
94 |
95 |
96 | 101 |
102 |
103 | 104 |

105 | 数码产品 107 |

108 |
109 |
110 | 111 |

112 | 图书教材 114 |

115 |
116 |
117 | 118 |

119 | 美妆服饰 121 |

122 |
123 |
124 | 125 |

126 | 生活其他 128 |

129 |
130 |
131 |
132 |
133 |
134 | 135 | 136 | 137 |
138 |
139 |
140 |

人气单品

141 |
142 |
143 | 1 144 | 1 145 | 2 146 | 3 147 | 4 148 | 5 149 | 5 150 |
151 |
152 | 154 |
155 | 157 |
158 | 159 |
160 |
161 |
162 |
163 | 164 | 165 | 166 | -------------------------------------------------------------------------------- /WebRoot/js/time.js: -------------------------------------------------------------------------------- 1 | // JavaScript Document 2 | var gMonths=new Array("一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"); 3 | var WeekDay=new Array("日","一","二","三","四","五","六"); 4 | var strToday="今天"; 5 | var strYear="年"; 6 | var strMonth="月"; 7 | var strDay="日"; 8 | var splitChar="-"; 9 | var startYear=2000; 10 | var endYear=2050; 11 | var dayTdHeight=12; 12 | var dayTdTextSize=12; 13 | var gcNotCurMonth="#E0E0E0"; 14 | var gcRestDay="#FF0000"; 15 | var gcWorkDay="#444444"; 16 | var gcMouseOver="#79D0FF"; 17 | var gcMouseOut="#F4F4F4"; 18 | var gcToday="#444444"; 19 | var gcTodayMouseOver="#6699FF"; 20 | var gcTodayMouseOut="#79D0FF"; 21 | var gdCtrl=new Object(); 22 | var goSelectTag=new Array(); 23 | var gdCurDate=new Date(); 24 | var giYear=gdCurDate.getFullYear(); 25 | var giMonth=gdCurDate.getMonth()+1; 26 | var giDay=gdCurDate.getDate(); 27 | function $(){var elements=new Array();for(var i=0;i10)?-1:1;}iMonth+=iOffset;if(iMonth<1){iYear--;iMonth=12;}else if(iMonth>12){iYear++;iMonth=1;}}fSetDate(iYear,iMonth,iDay);} 37 | function Point(iX,iY){this.x=iX;this.y=iY;} 38 | function fBuildCal(iYear,iMonth){var aMonth=new Array();for(var i=1;i<7;i++){aMonth[i]=new Array(i);}var dCalDate=new Date(iYear,iMonth-1,1);var iDayOfFirst=dCalDate.getDay();var iDaysInMonth=new Date(iYear,iMonth,0).getDate();var iOffsetLast=new Date(iYear,iMonth-1,0).getDate()-iDayOfFirst+1;var iDate=1;var iNext=1;for(var d=0;d<7;d++){aMonth[1][d]=(d"+WeekDay[i]+"";}dateCal+="";for(var w=1;w<7;w++){dateCal+="";for(var d=0;d<7;d++){var tmpid=w+""+d;dateCal+="";dateCal+="";dateCal+="";}dateCal+="";}return dateCal;} 40 | function fUpdateCal(iYear,iMonth){var myMonth=fBuildCal(iYear,iMonth);var i=0;for(var w=1;w<7;w++){for(var d=0;d<7;d++){with($("cellText"+w+""+d)){parentNode.bgColor=gcMouseOut;parentNode.borderColor=gcMouseOut;parentNode.onmouseover=function(){this.bgColor=gcMouseOver;};parentNode.onmouseout=function(){this.bgColor=gcMouseOut;};if(myMonth[w][d]<0){style.color=gcNotCurMonth;innerHTML=Math.abs(myMonth[w][d]);}else{style.color=((d==0)||(d==6))?gcRestDay:gcWorkDay;innerHTML=myMonth[w][d];if(iYear==giYear && iMonth==giMonth && myMonth[w][d]==giDay){style.color=gcToday;parentNode.bgColor=gcTodayMouseOut;parentNode.onmouseover=function(){this.bgColor=gcTodayMouseOver;};parentNode.onmouseout=function(){this.bgColor=gcTodayMouseOut;};}}}}}} 41 | function fSetYearMon(iYear,iMon){$("tbSelMonth").options[iMon-1].selected=true;for(var i=0;i<$("tbSelYear").length;i++){if($("tbSelYear").options[i].value==iYear){$("tbSelYear").options[i].selected=true;}}fUpdateCal(iYear,iMon);} 42 | function fPrevMonth(){var iMon=$("tbSelMonth").value;var iYear=$("tbSelYear").value;if(--iMon<1){iMon=12;iYear--;}fSetYearMon(iYear,iMon);} 43 | function fNextMonth(){var iMon=$("tbSelMonth").value;var iYear=$("tbSelYear").value;if(++iMon>12){iMon=1;iYear++;}fSetYearMon(iYear,iMon);} 44 | function fGetXY(aTag){var oTmp=aTag;var pt=new Point(0,0);do{pt.x+=oTmp.offsetLeft;pt.y+=oTmp.offsetTop;oTmp=oTmp.offsetParent;}while(oTmp.tagName.toUpperCase()!="BODY");return pt;} 45 | function getDateDiv(){var noSelectForIE="";var noSelectForFireFox="";if(document.all){noSelectForIE="onselectstart='return false;'";}else{noSelectForFireFox="-moz-user-select:none;";}var dateDiv="";dateDiv+="";return dateDiv;} 46 | with(document){onclick=fHideCalendar;write(getDateDiv());} -------------------------------------------------------------------------------- /WebRoot/WEB-INF/jsp/front/ShowCar.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" import="java.util.*" 2 | contentType="text/html; charset=utf-8"%> 3 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 4 | <%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> 5 | <% 6 | String path = request.getContextPath(); 7 | String basePath = request.getScheme() + "://" 8 | + request.getServerName() + ":" + request.getServerPort() 9 | + path + "/"; 10 | %> 11 | 12 | 13 | 14 | 15 | 购物车 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 50 | 51 | 52 | 53 | 54 |
55 |
56 |
57 | 58 | 59 |
60 |
61 | 65 | 66 |
67 | 97 |
98 | 99 | 106 | 107 |
108 |
109 |
110 | 115 |
116 | 117 |
118 | 119 | 120 | 121 | 122 |
123 |
124 |
125 |

我的购物车

126 | 127 | 128 | 129 |
130 | camera
133 |
135 |
136 |
137 | 138 |
139 | camera
142 |
144 |
145 |
146 | 147 |
148 | camera
151 |
153 |
154 |
155 | 156 |
157 | camera
160 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 | 173 | 174 | 175 |
176 | camera
179 |
181 |
182 |
183 | 184 |
185 | camera
188 |
190 |
191 |
192 | 193 |
194 | camera
197 |
199 |
200 |
201 | 202 |
203 | camera
206 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 | 216 |
217 | 218 | 219 |
220 | 221 |
222 | 223 | 224 |
225 | 226 | 227 | -------------------------------------------------------------------------------- /src/dao/ItemsDaoImpl.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import java.sql.SQLException; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | import util.JdbcUtil; 9 | 10 | 11 | 12 | import model.Items; 13 | import model.Pager; 14 | 15 | 16 | 17 | /** 18 | * 使用mysql数据库limit关键字实现分页 19 | */ 20 | public class ItemsDaoImpl implements ItemsDao { 21 | 22 | //根据商品名称分页查询 23 | @Override 24 | public Pager findItems(Items searchModel, int pageNum, 25 | int pageSize) { 26 | Pager result = null; 27 | // 存放查询参数 28 | List paramList = new ArrayList(); 29 | 30 | String name = searchModel.getName(); 31 | 32 | StringBuilder sql = new StringBuilder( 33 | "select id,image,name,discription,price,contact,hot from items where 1=1"); 34 | StringBuilder countSql = new StringBuilder( 35 | "select count(id) as totalRecord from items where 1=1 "); 36 | 37 | if (name != null && !name.equals("")) { 38 | sql.append(" and name like ?"); 39 | countSql.append(" and name like ?"); 40 | paramList.add("%" + name + "%"); 41 | } 42 | // 起始索引 43 | int fromIndex = pageSize * (pageNum -1); 44 | 45 | // 使用limit关键字,实现分页 46 | sql.append(" limit " + fromIndex + ", " + pageSize ); 47 | 48 | // 存放所有查询出的商品对象 49 | List itemsList = new ArrayList(); 50 | JdbcUtil jdbcUtil = null; 51 | try { 52 | jdbcUtil = new JdbcUtil(); 53 | jdbcUtil.getConnection(); // 获取数据库链接 54 | 55 | // 获取总记录数 56 | List> countResult = jdbcUtil.findResult(countSql.toString(), paramList); 57 | Map countMap = countResult.get(0); 58 | int totalRecord = ((Number)countMap.get("totalRecord")).intValue(); 59 | 60 | // 获取查询的商品记录 61 | List> itemsResult = jdbcUtil.findResult(sql.toString(), paramList); 62 | if (itemsResult != null) { 63 | System.out.println("遍历商品:"); 64 | for (Map map : itemsResult) { 65 | Items s = new Items(map); 66 | itemsList.add(s); 67 | System.out.println(s); 68 | } 69 | } 70 | 71 | //获取总页数 72 | int totalPage = totalRecord / pageSize; 73 | if(totalRecord % pageSize !=0){ 74 | totalPage++; 75 | } 76 | 77 | // 组装pager对象 78 | result = new Pager(pageSize, pageNum, 79 | totalRecord, totalPage, itemsList); 80 | 81 | } catch (SQLException e) { 82 | throw new RuntimeException("查询所有数据异常!", e); 83 | } finally { 84 | if (jdbcUtil != null) { 85 | jdbcUtil.releaseConn(); // 一定要释放资源 86 | } 87 | } 88 | return result; 89 | } 90 | 91 | //获取单个商品 92 | @Override 93 | public List getOneItem(int id) { 94 | List itemsList = new ArrayList(); 95 | StringBuffer sql = new StringBuffer("select id,image,name,discription,price,contact,hot from items "); 96 | 97 | // 存放查询参数 98 | List paramList = new ArrayList(); 99 | 100 | sql.append(" where id=? "); 101 | paramList.add(id); 102 | JdbcUtil jdbcUtil = null; 103 | try { 104 | jdbcUtil = new JdbcUtil(); 105 | jdbcUtil.getConnection(); // 获取数据库链接 106 | 107 | // 获取查询的商品记录 108 | List> itemsResult = jdbcUtil.findResult(sql.toString(), paramList); 109 | if (itemsResult != null) { 110 | for (Map map : itemsResult) { 111 | Items s = new Items(map); 112 | itemsList.add(s); 113 | System.out.println("查询单个商品:"+s.toString()); 114 | } 115 | } 116 | } catch (SQLException e) { 117 | throw new RuntimeException("查询单个数据异常!", e); 118 | } finally { 119 | if (jdbcUtil != null) { 120 | jdbcUtil.releaseConn(); // 释放资源 121 | } 122 | } 123 | return itemsList; 124 | } 125 | 126 | //更新商品热度 127 | @Override 128 | public boolean addItemHot(int id) { 129 | StringBuffer sql = new StringBuffer("update items set hot = hot+100 where id=? "); 130 | 131 | // 存放查询参数 132 | List paramList = new ArrayList(); 133 | 134 | paramList.add(id); 135 | JdbcUtil jdbcUtil = null; 136 | try { 137 | jdbcUtil = new JdbcUtil(); 138 | jdbcUtil.getConnection(); // 获取数据库链接 139 | 140 | // 获取查询的商品记录 141 | boolean flag = jdbcUtil.updateByPreparedStatement(sql.toString(), paramList); 142 | System.out.println("更新商品热度成功"); 143 | return flag; 144 | } catch (SQLException e) { 145 | throw new RuntimeException("查询单个数据异常!", e); 146 | } finally { 147 | if (jdbcUtil != null) { 148 | jdbcUtil.releaseConn(); // 释放资源 149 | } 150 | } 151 | } 152 | 153 | /** 154 | * 购买商品 155 | */ 156 | @Override 157 | public boolean buyItem(int userID, Items buyItem, String buy_Time) { 158 | List paramList = new ArrayList(); 159 | StringBuilder sql = new StringBuilder( 160 | "insert into buy_items(itemID,itemName,buy_Time,userID,itemPrice,itemNumber) values(?,?,?,?,?,?)"); 161 | paramList.add(buyItem.getId()); 162 | paramList.add(buyItem.getName()); 163 | paramList.add(buy_Time); 164 | paramList.add(userID); 165 | paramList.add(buyItem.getPrice()); 166 | paramList.add(buyItem.getNumber()); 167 | 168 | JdbcUtil jdbcUtil = null; 169 | try { 170 | jdbcUtil = new JdbcUtil(); 171 | jdbcUtil.getConnection(); // 获取数据库链接 172 | 173 | // 添加的商品信息 174 | boolean flag = jdbcUtil.updateByPreparedStatement(sql.toString(), paramList); 175 | if(flag==true){ 176 | System.out.println("用户:"+userID+"购买商品"+buyItem.toString()+"时间:"+buy_Time); 177 | } 178 | return flag; 179 | } catch (SQLException e) { 180 | throw new RuntimeException("查询所有数据异常!", e); 181 | } finally { 182 | if (jdbcUtil != null) { 183 | jdbcUtil.releaseConn(); // 一定要释放资源 184 | } 185 | } 186 | } 187 | 188 | @Override 189 | public Pager typeItems(Items searchModel, int pageNum, int pageSize) { 190 | Pager result = null; 191 | // 存放查询参数 192 | List paramList = new ArrayList(); 193 | 194 | String type = searchModel.getType(); 195 | 196 | StringBuilder sql = new StringBuilder( 197 | "select id,image,name,discription,price,contact,hot from items where 1=1"); 198 | StringBuilder countSql = new StringBuilder( 199 | "select count(id) as totalRecord from items where 1=1 "); 200 | 201 | if (type != null && !type.equals("")) { 202 | sql.append(" and type = ? "); 203 | countSql.append(" and type = ? "); 204 | paramList.add(type); 205 | } 206 | // 起始索引 207 | int fromIndex = pageSize * (pageNum -1); 208 | 209 | // 使用limit关键字,实现分页 210 | sql.append(" limit " + fromIndex + ", " + pageSize ); 211 | 212 | // 存放所有查询出的商品对象 213 | List itemsList = new ArrayList(); 214 | JdbcUtil jdbcUtil = null; 215 | try { 216 | jdbcUtil = new JdbcUtil(); 217 | jdbcUtil.getConnection(); // 获取数据库链接 218 | 219 | // 获取总记录数 220 | List> countResult = jdbcUtil.findResult(countSql.toString(), paramList); 221 | Map countMap = countResult.get(0); 222 | int totalRecord = ((Number)countMap.get("totalRecord")).intValue(); 223 | 224 | // 获取查询的商品记录 225 | List> itemsResult = jdbcUtil.findResult(sql.toString(), paramList); 226 | if (itemsResult != null) { 227 | System.out.println("遍历商品:"); 228 | for (Map map : itemsResult) { 229 | Items s = new Items(map); 230 | itemsList.add(s); 231 | System.out.println(s); 232 | } 233 | } 234 | 235 | //获取总页数 236 | int totalPage = totalRecord / pageSize; 237 | if(totalRecord % pageSize !=0){ 238 | totalPage++; 239 | } 240 | 241 | // 组装pager对象 242 | result = new Pager(pageSize, pageNum, 243 | totalRecord, totalPage, itemsList); 244 | 245 | } catch (SQLException e) { 246 | throw new RuntimeException("查询所有数据异常!", e); 247 | } finally { 248 | if (jdbcUtil != null) { 249 | jdbcUtil.releaseConn(); // 一定要释放资源 250 | } 251 | } 252 | return result; 253 | } 254 | 255 | //添加商品信息,发布商品 256 | @Override 257 | public boolean addItem(Items additem) { 258 | List paramList = new ArrayList(); 259 | StringBuilder sql = new StringBuilder( 260 | "insert into items(image,name,discription,price,contact,type) values(?,?,?,?,?,?)"); 261 | 262 | String image = additem.getImage(); 263 | if (image != null && !image.equals("")) { 264 | paramList.add(image); 265 | } 266 | String name = additem.getName(); 267 | if (name != null && !name.equals("")) { 268 | paramList.add(name); 269 | } 270 | String discription = additem.getDiscription(); 271 | if (discription != null && !discription.equals("")) { 272 | paramList.add(discription); 273 | } 274 | int price = additem.getPrice(); 275 | if (price != 0) { 276 | paramList.add(price); 277 | } 278 | String contact = additem.getContact(); 279 | if (contact != null && !contact.equals("")) { 280 | paramList.add(contact); 281 | } 282 | String type = additem.getType(); 283 | if (type != null && !type.equals("")) { 284 | paramList.add(type); 285 | } 286 | 287 | JdbcUtil jdbcUtil = null; 288 | try { 289 | jdbcUtil = new JdbcUtil(); 290 | jdbcUtil.getConnection(); // 获取数据库链接 291 | 292 | // 添加的商品信息 293 | boolean flag = jdbcUtil.updateByPreparedStatement(sql.toString(), paramList); 294 | if(flag==true){ 295 | System.out.println("添加商品:"+additem.toString()); 296 | } 297 | return flag; 298 | } catch (SQLException e) { 299 | throw new RuntimeException("添加商品信息异常!", e); 300 | } finally { 301 | if (jdbcUtil != null) { 302 | jdbcUtil.releaseConn(); // 一定要释放资源 303 | } 304 | } 305 | } 306 | 307 | 308 | } 309 | --------------------------------------------------------------------------------