当前位置: 首页 > news >正文

淘宝客cms网站建设设计效果图怎么做

淘宝客cms网站建设,设计效果图怎么做,老师找学生做网站是什么心态,张家港优化网站seo用Jsp Servlet和Jquery以及SQLServer实现商品管理系统。 采用MVC三层架构进行此程序的开发。 功能分析#xff1a; 1.登录功能 2.查询和联合查询商品 3.增加商品 4.删除商品 效果演示 登录页面 查询页面 添加商品 点击删除 实现商品管理系统需要数据库和程序两部分。…用Jsp Servlet和Jquery以及SQLServer实现商品管理系统。 采用MVC三层架构进行此程序的开发。 功能分析 1.登录功能 2.查询和联合查询商品 3.增加商品 4.删除商品 效果演示 登录页面 查询页面 添加商品 点击删除 实现商品管理系统需要数据库和程序两部分。 一 数据库 参考下面图片进行设计和实现SQLserver数据库 二程序设计 我们先看一下程序目录结构 特别注意 需要引入sqljdbc.jar和jquery.js两个架包 完整代码 servlet包 servlet包里DeleteServlet.java package com.hnpi.servlet;import java.io.IOException; import java.io.PrintWriter; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException;import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;import com.hnpi.util.DBUtil;public class DeleteServlet extends HttpServlet {public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {doPost(request, response);}public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {response.setContentType(text/html);PrintWriter out response.getWriter();String id request.getParameter(id);String sql delete from Product where ProductID ?;Connection conn DBUtil.getconn();try {System.out.println(sql);PreparedStatement ps conn.prepareStatement(sql);ps.setInt(1,Integer.parseInt(id));ps.executeUpdate();response.sendRedirect(list);} catch (SQLException e) {// TODO Auto-generated catch blocke.printStackTrace();}out.flush();out.close();}} servlet包里InsertServlet.java package com.hnpi.servlet;import java.io.IOException; import java.io.PrintWriter; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException;import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;import com.hnpi.util.DBUtil;public class InsertServlet extends HttpServlet {public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {doPost(request, response);}public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {response.setContentType(text/html);PrintWriter out response.getWriter();String ProductName new String(request.getParameter(ProductName).getBytes(iso-8859-1),utf-8);String IsUp new String(request.getParameter(IsUp).getBytes(iso-8859-1),utf-8);String UnitPrice new String(request.getParameter(UnitPrice).getBytes(iso-8859-1),utf-8);String Remark new String(request.getParameter(Remark).getBytes(iso-8859-1),utf-8);String CategoryID new String(request.getParameter(CategoryID).getBytes(iso-8859-1),utf-8);String sql insert into Product values(?,?,?,?,?);Connection conn DBUtil.getconn();try {System.out.println(sql);PreparedStatement ps conn.prepareStatement(sql);ps.setString(1,ProductName);ps.setString(2,IsUp);ps.setInt(3, Integer.parseInt(UnitPrice));ps.setString(4,Remark);ps.setInt(5, Integer.parseInt(CategoryID));if(ps.executeUpdate()0){response.sendRedirect(list);}} catch (SQLException e) {// TODO Auto-generated catch blocke.printStackTrace();}out.flush();out.close();}} servlet包里ListServlet.java package com.hnpi.servlet;import java.io.IOException; import java.io.PrintWriter; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException;import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession;import com.hnpi.util.DBUtil;public class ListServlet extends HttpServlet {public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {doPost(request, response);}public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {request.setCharacterEncoding(utf-8);response.setCharacterEncoding(utf-8);PrintWriter out response.getWriter();//接受从查询页面传过来的值String ProductName request.getParameter(ProductName);String Remark request.getParameter(Remark);HttpSession session request.getSession();//联合查询// select b表的所有a表的名字 from a表 as a, b表 as b where b.b表的id a.a表的idString sql select b.* ,a.CategoryName from Category as a , Product as b where b.CategoryID a.CategoryID;//判断是否为空if(!.equals(ProductName) ProductName!null){ProductName new String(ProductName.getBytes(iso-8859-1),utf-8);sql sql and b.ProductName \ProductName\;}if(!.equals(Remark) Remark!null){Remark new String(Remark.getBytes(iso-8859-1),utf-8);sql sql and b.Remark \Remark\;}//列表Connection conn DBUtil.getconn();try {System.out.println(sql);PreparedStatement ps conn.prepareStatement(sql);ResultSet rs ps.executeQuery();session.setAttribute(set, rs);} catch (SQLException e) {// TODO Auto-generated catch blocke.printStackTrace();}//类别try {String sq select * from Category;PreparedStatement ps conn.prepareStatement(sq);ResultSet rs ps.executeQuery();session.setAttribute(se, rs);} catch (SQLException e) {// TODO Auto-generated catch blocke.printStackTrace();}response.sendRedirect(list.jsp);out.flush();out.close();}} servlet包里LoginServlet.java package com.hnpi.servlet;import java.awt.image.DataBufferUShort; import java.io.IOException; import java.io.PrintWriter; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException;import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;import com.hnpi.util.DBUtil;public class LoginServlet extends HttpServlet {public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {doPost(request, response);}public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {request.setCharacterEncoding(utf-8);response.setCharacterEncoding(utf-8);String name request.getParameter(name);String pwd request.getParameter(pwd);Connection conn DBUtil.getconn();PreparedStatement ps null;ResultSet rs null;String sql select * from Userinfo where UserName ? and Password ?;try {ps conn.prepareStatement(sql);ps.setString(1, name);ps.setString(2, pwd);rs ps.executeQuery();if(rs.next()){response.sendRedirect(list);}else{response.sendRedirect(login.jsp);}} catch (SQLException e) {// TODO Auto-generated catch blocke.printStackTrace();}}} util包 util包里DBUtil.java package com.hnpi.util;import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException;public class DBUtil {public static Connection getconn(){try {Class.forName(com.microsoft.sqlserver.jdbc.SQLServerDriver);} catch (ClassNotFoundException e) {// TODO Auto-generated catch blocke.printStackTrace();}Connection conn null;try {conn DriverManager.getConnection(jdbc:sqlserver://localhost:1433;databaseNameTest,sa,1);} catch (SQLException e) {// TODO Auto-generated catch blocke.printStackTrace();}return conn;} } WEB-INF包 web.xml ?xml version1.0 encodingUTF-8? web-app version2.5 xmlnshttp://java.sun.com/xml/ns/javaee xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance xsi:schemaLocationhttp://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsddisplay-name/display-nameservletdescriptionThis is the description of my J2EE component/descriptiondisplay-nameThis is the display name of my J2EE component/display-nameservlet-nameLoginServlet/servlet-nameservlet-classcom.hnpi.servlet.LoginServlet/servlet-class/servletservletdescriptionThis is the description of my J2EE component/descriptiondisplay-nameThis is the display name of my J2EE component/display-nameservlet-nameListServlet/servlet-nameservlet-classcom.hnpi.servlet.ListServlet/servlet-class/servletservletdescriptionThis is the description of my J2EE component/descriptiondisplay-nameThis is the display name of my J2EE component/display-nameservlet-nameDeleteServlet/servlet-nameservlet-classcom.hnpi.servlet.DeleteServlet/servlet-class/servletservletdescriptionThis is the description of my J2EE component/descriptiondisplay-nameThis is the display name of my J2EE component/display-nameservlet-nameInsertServlet/servlet-nameservlet-classcom.hnpi.servlet.InsertServlet/servlet-class/servletservlet-mappingservlet-nameLoginServlet/servlet-nameurl-pattern/login/url-pattern/servlet-mappingservlet-mappingservlet-nameListServlet/servlet-nameurl-pattern/list/url-pattern/servlet-mappingservlet-mappingservlet-nameDeleteServlet/servlet-nameurl-pattern/del/url-pattern/servlet-mappingservlet-mappingservlet-nameInsertServlet/servlet-nameurl-pattern/insert/url-pattern/servlet-mapping welcome-file-listwelcome-filelogin.jsp/welcome-file/welcome-file-list /web-app Jsp页面 add.jsp %page importjava.sql.ResultSet% % page languagejava importjava.util.* pageEncodingutf-8% % String path request.getContextPath(); String basePath request.getScheme()://request.getServerName():request.getServerPort()path/; %!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN htmlheadbase href%basePath%titleMy JSP add.jsp starting page/titlemeta http-equivpragma contentno-cachemeta http-equivcache-control contentno-cachemeta http-equivexpires content0 meta http-equivkeywords contentkeyword1,keyword2,keyword3meta http-equivdescription contentThis is my page!--link relstylesheet typetext/css hrefstyles.css--/headbodyform actioninsert商品名称input idProductName name ProductName/br/是否上架input idIsUp typeradio name IsUp value是/是input typeradio name IsUp value否/否br/单价input typenumber idUnitPrice name UnitPrice/br/备注textarea idRemark rows5 cols20 nameRemark/textareabr/所属类别:select idCategoryID name CategoryID% ResultSet rs (ResultSet)session.getAttribute(se);while(rs.next()){%option value%rs.getString(1) %%rs.getString(2) %/option%}%/selectbr/input typesubmit value提交/form/bodyscript typetext/javascript srcjquery-3.3.1.js/scriptscript typetext/javascript $(function(){$(form).submit(function(){var ProductName $(#ProductName).val();var IsUp $(#IsUp).val();var UnitPrice $(#UnitPrice).val();var Remark $(#Remark).val();if(ProductName||IsUp||UnitPrice||Remark){alert(请补充完整信息)return false;}else{return true;}}) })/body /html list.jsp %page importjava.sql.ResultSet% % page languagejava importjava.util.* pageEncodingutf-8% % String path request.getContextPath(); String basePath request.getScheme()://request.getServerName():request.getServerPort()path/; %!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN htmlheadbase href%basePath%titleMy JSP list.jsp starting page/titlemeta http-equivpragma contentno-cachemeta http-equivcache-control contentno-cachemeta http-equivexpires content0 meta http-equivkeywords contentkeyword1,keyword2,keyword3meta http-equivdescription contentThis is my page!--link relstylesheet typetext/css hrefstyles.css--/headbodycenterform actionlist商品名称input name ProductName商品备注input name Remarkinput typesubmit value查询buttona hrefadd.jsp添加商品/a/button/formtable border1 cellspacing0trth编号/thth商品名称/thth是否上架/thth单价/thth备注/thth所属类别/thth操作/th/tr% ResultSet rs (ResultSet)session.getAttribute(set);while(rs.next()){%trth%rs.getString(1) %/thth%rs.getString(2) %/thth%rs.getString(3) %/thth%rs.getString(4) %/thth%rs.getString(5) %/thth%rs.getString(7) %/ththbuttona hrefdel?id%rs.getString(1) % 删除/a/button/th/tr%}%/table/center/body /html login.jsp % page languagejava importjava.util.* pageEncodingutf-8% %String path request.getContextPath();String basePath request.getScheme() :// request.getServerName() : request.getServerPort() path /; %!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN html head base href%basePath%titleMy JSP index.jsp starting page/title meta http-equivpragma contentno-cache meta http-equivcache-control contentno-cache meta http-equivexpires content0 meta http-equivkeywords contentkeyword1,keyword2,keyword3 meta http-equivdescription contentThis is my page !--link relstylesheet typetext/css hrefstyles.css-- /headbodyform actionlogin账号input idname namenamebr / 密码input idpwdnamepwdbr / input typesubmit/form /body script typetext/javascript srcjquery-3.3.1.js/script script typetext/javascript$(function() {$(form).submit(function() {var name $(#name).val();var pwd $(#pwd).val();if ( name) {alert(请输入账号)return false;} else if ( pwd) {alert(请输入密码)return false;} else {return true;}})}) /script /body /html 我们已经把商品管理系统完整实现了。 扫一扫关注我的公众号获取更多资讯
http://www.zqtcl.cn/news/440985/

相关文章:

  • 法语网站建设免费网站为何收录比较慢
  • 品牌网站推广软件seo内链优化
  • 广东律师事务所东莞网站建设做网站 怎么备案
  • shopnc本地生活o2o网站源码wordpress文章内多页效果
  • 深圳全国网站制作哪个好页面设计有哪几种风格
  • 网页设计作业网站素材和效果图夏天做啥网站致富
  • 利用帝国软件如何做网站网站友链交换平台
  • 简述网站开发技术深圳网站设计合理刻
  • wordpress网站名称寻找销售团队外包
  • 一浪网站建设网页qq邮箱
  • 做网站需要注册公司吗夫唯seo系统培训
  • 沈阳人流哪个医院好安全百度关键词优化怎么做
  • 1688网站怎么做分销高质量的网站内容建设
  • 网站建设公司济宁网站转跳怎么做
  • 镇江网站设计多少钱企业网络部署方案
  • 建网站的公司浩森宇特wordpress登录缓存
  • 便宜建站空间战队头像在线制作免费
  • 做招聘网站赚钱吗厦门网站建设哪里好
  • 新乡网站建设哪家公司好阿里巴巴做国际网站多少钱
  • 怎么在悉尼做网站dede做手机网站
  • 企业网站模板免费下载品牌建设专家库推荐表
  • 辽宁智能网站建设推荐网络营销推广方案创意
  • 安阳做一个网站多少钱东营做网站公司
  • 深圳市罗湖网站建设百度自助建站官网
  • 网站开发安装环境网站建设销售话术
  • 网站权重网站栏目划分的原则
  • 国际网站建设的目的我的百度账号登录
  • 温州网站设计定制博客和网站的区别
  • 益阳建设网站wordpress加载图片慢
  • 网站官网阜新网站开发公司