- 浏览: 24494 次
- 性别:
文章分类
create database demodb_info go USE demodb_info GO --drop database demodb_info /****** Object: Table [dbo].[t_book] Script Date: 12/13/2012 17:28:38 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO --drop table [dbo].[t_book] CREATE TABLE [dbo].[t_book]( [id] [int] NOT NULL, [name] [varchar](20) NULL, [auther] [varchar](20) NULL, [press] [varchar](20) NULL, [price] [money] NULL, CONSTRAINT [PK_t_book] PRIMARY KEY CLUSTERED ( [id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO SET ANSI_PADDING OFF GO /****** Script for SelectTopNRows command from SSMS ******/ SELECT TOP 1000 [id] ,[name] ,[auther] ,[press] ,[price] FROM demodb_info.[dbo].[t_book] go --delete FROM demodb_info.[dbo].[t_book] go insert into demodb_info.[dbo].[t_book] values(1,'秘密','拜恩','中国城市出版社',17.3); insert into demodb_info.[dbo].[t_book] values(2,'白鹿原','陈忠实','北京十月文艺出版社',22); insert into demodb_info.[dbo].[t_book] values(3,'青春','韩寒','湖南人民出版社',20.3); insert into demodb_info.[dbo].[t_book] values(4,'追风筝的人','胡赛尼','上海人民出版社',16.3); insert into demodb_info.[dbo].[t_book] values(5,'狼图腾','姜戎','长江文艺出版社',21.1); insert into demodb_info.[dbo].[t_book] values(6,'正能量','理查德 怀斯曼民','湖南文艺出版社',18.5); insert into demodb_info.[dbo].[t_book] values(7,'好妈妈胜过好老师','尹建莉','作家出版社',14.3); insert into demodb_info.[dbo].[t_book] values(8,'你若安好便是晴天','白落梅','中国华侨出版社',17.4); insert into demodb_info.[dbo].[t_book] values(9,'不一样的卡梅拉','克利斯提昂','二十一世纪出版社',26.5); insert into demodb_info.[dbo].[t_book] values(10,'因为痛 所以叫青春','金兰都','广西科学技术出版社',19.7);
package com.Bookinfo.web.util; public class Book { private int id; private String name; private String author; private String press; private double price; public Book(int id, String name, String author, String press, double price) { super(); this.id = id; this.name = name; this.author = author; this.press = press; this.price = price; } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getAuthor() { return author; } public void setAuthor(String author) { this.author = author; } public String getPress() { return press; } public void setPress(String press) { this.press = press; } public double getPrice() { return price; } public void setPrice(double price) { this.price = price; } }
//登陆的servlet 没有和数据库连接 package com.Bookinfo.Servlet.util; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; public class LoginServlet extends HttpServlet { public void doPost(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException{ PrintWriter out=response.getWriter(); // response.setContentType("text/html;charset=UTF-8"); String name=request.getParameter("loginName"); String pwd=request.getParameter("loginPwd"); //初始化购物车 List<Integer> cart=new ArrayList<Integer>(); if(name.equals("admin") && pwd.equals("123")){ HttpSession sess=request.getSession(); //将购物车放到session对象中 name=new String(name.getBytes("ISO-8859-1"),"UTF-8"); sess.setAttribute("userName", name); sess.setAttribute("cartFrist",cart); //request.getRequestDispatcher("index.jsp").forward(request, response); response.sendRedirect("index.jsp"); }else{ out.println("登录失败!"); } out.flush(); out.close(); } }
package com.Bookinfo.BFace.util; import java.util.List; import com.Bookinfo.web.util.Book; //接口 返回List集合 public interface BookInter { public List<Book> getBook(); }
package com.Bookinfo.BImple.util; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; import java.util.ArrayList; import java.util.List; import com.Bookinfo.BFace.util.BookInter; import com.Bookinfo.web.util.Book; public class Bimple implements BookInter { public Connection conn=null; public Statement stm=null; public ResultSet rs=null; public List<Book> getBook() { // TODO Auto-generated method stub List<Book> books=new ArrayList<Book>(); try { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); conn=DriverManager.getConnection("jdbc:sqlserver://localhost:1433;database=demodb_info","sa","svse"); stm=conn.createStatement(); rs=stm.executeQuery("select * from [dbo].[t_book]"); while(rs.next()){ int id=rs.getInt(1); String name=rs.getString(2); String author=rs.getString(3); String press=rs.getString(4); double price=rs.getDouble(5); Book b=new Book(id,name,author,press,price); books.add(b); } } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } return books; } }
package com.Bookinfo.Servlet.util; import java.io.IOException; import java.util.List; import javax.servlet.ServletConfig; 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.Bookinfo.BFace.util.BookInter; import com.Bookinfo.BImple.util.Bimple; import com.Bookinfo.web.util.Book; public class GetServlet extends HttpServlet { private ServletConfig config; public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException{ config=this.getServletConfig(); String school=config.getInitParameter("school"); System.out.println(school); response.setContentType("text/html;charset=UTF-8"); HttpSession sess=request.getSession(); BookInter bt=new Bimple(); List<Book> listbobo=bt.getBook(); System.out.println(bt.getBook().size()); sess.setAttribute("book",listbobo); //request.getRequestDispatcher("BookTable.jsp").forward(request, response); response.sendRedirect("BookTable.jsp"); } }
package com.Bookinfo.BFace.util; import java.util.List; import com.Bookinfo.web.util.Book; public interface CartIface { //根据图书ID查血图书信息 public Book getBookById(int id); }
package com.Bookinfo.BImple.util; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; import java.util.ArrayList; import java.util.List; import com.Bookinfo.BFace.util.BookInter; import com.Bookinfo.BFace.util.CartIface; import com.Bookinfo.web.util.Book; public class CartImple implements CartIface { public Connection conn=null; public Statement stm=null; public ResultSet rs=null; public Book getBookById(int id) { // TODO Auto-generated method stub List<Book> books=new ArrayList<Book>(); Book book_cart=null; try { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); conn=DriverManager.getConnection("jdbc:sqlserver://localhost:1433;database=demodb_info","sa","svse"); stm=conn.createStatement(); rs=stm.executeQuery("select * from t_book where id='"+id+"'"); while(rs.next()){ Integer bookId=rs.getInt(1); String name=rs.getString(2); String author=rs.getString(3); String press=rs.getString(4); double price=rs.getDouble(5); Book b=new Book(bookId,name,author,press,price); books.add(b); } book_cart=books.get(0); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); }finally{ try { //关闭ResultSet if(rs!=null){rs.close();} //关闭PreparedStatement if(stm!=null){stm.close();} //关闭Connection if(conn!=null){conn.close();} } catch (Exception e) { e.printStackTrace(); } } return book_cart; }
package com.Bookinfo.Servlet.util; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; public class CartServlet extends HttpServlet { /** * The doGet method of the servlet. <br> * * This method is called when a form has its tag value method equals to get. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); HttpSession sess=request.getSession(); String bookId=request.getParameter("bookId");//得到用户购买的图书的id //将用户的图书的id存放到购物车中去中 List<Integer> cart=(List<Integer>)sess.getAttribute("cartFrist"); //将图书id添加进去 cart.add(Integer.parseInt(bookId)); } }
package com.Bookinfo.Servlet.util; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; 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.Bookinfo.BFace.util.CartIface; import com.Bookinfo.BImple.util.CartImple; import com.Bookinfo.web.util.Book; public class CartMessageServlet extends HttpServlet { /** * The doGet method of the servlet. <br> * * This method is called when a form has its tag value method equals to get. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); CartIface ciface=new CartImple(); HttpSession sess=request.getSession(); List<Integer> listCartID=(List<Integer>) sess.getAttribute("cartFrist"); List<Book> listbook=new ArrayList<Book>(); for (int i = 0; i <listCartID.size(); i++) { Book bo=ciface.getBookById(listCartID.get(i)); listbook.add(bo); } sess.setAttribute("CartMessage",listbook); response.sendRedirect("cartMessage.jsp"); } }
<%@ page language="java" import="java.util.*" pageEncoding="UTF-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%>"> <title>My JSP 'index.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> <a href="Login.jsp">登陆</a> <%=session.getAttribute("userName") %> <a href="bookTable">查看信息</a> <a href="CartMessageServlet">查看购物车</a> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-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%>"> <title>My JSP 'Login.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> <div align="center"><form action="loginUser" method="post"> 用户名: <input type="text" name="loginName"> <br/> 密码: <input type="text" name="loginPwd"> <br/> <input type="submit" value="确定"/> </form></div> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <%@ page import="com.Bookinfo.web.util.Book" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'BookTable.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> This is my table page. <br> <hr/> <center> <table> <tr> <td>图书Id</td> <td>图书名称</td> <td>图书作者</td> <td>图书出版社</td> <td>图书价格</td> <td>操作</td> </tr> <% List<Book> listBook=(ArrayList)session.getAttribute("book"); for(int i=0;i<listBook.size();i++){ Book b=listBook.get(i); %> <tr> <td><%=b.getId() %></td> <td><%=b.getName() %></td> <td><%=b.getAuthor() %></td> <td><%=b.getPress() %></td> <td><%=b.getPrice() %></td> <td><a href="CartServlet?bookId=<%=b.getId() %>">购买</a></td> </tr> <% } %> </table> </center> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <%@ page import="com.Bookinfo.web.util.Book" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'cartMessage.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> <center> <table> <%! double sum=0; %> <tr> <td>图书Id</td> <td>图书名称</td> <td>图书作者</td> <td>图书出版社</td> <td>图书价格</td> <td>操作</td> </tr> <% List<Book> listBook=(ArrayList)session.getAttribute("CartMessage"); sum=0; for(int i=0;i<listBook.size();i++){ Book b=listBook.get(i); sum=sum+b.getPrice(); %> <tr> <td><%=b.getId() %></td> <td><%=b.getName() %></td> <td><%=b.getAuthor() %></td> <td><%=b.getPress() %></td> <td><%=b.getPrice() %></td> <td><a href="#">删除</a></td> </tr> <% } %> <tr> <td clospan="6">总价格:<%=sum %></td> </tr> </table> </center> </body> </html>
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <servlet> <servlet-name>booktable</servlet-name> <servlet-class>com.Bookinfo.Servlet.util.GetServlet</servlet-class> <init-param> <param-name>school</param-name> <param-value>国资</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>booktable</servlet-name> <url-pattern>/bookTable</url-pattern> </servlet-mapping> <servlet> <servlet-name>loginuser</servlet-name> <servlet-class>com.Bookinfo.Servlet.util.LoginServlet</servlet-class> </servlet> <servlet> <description>将图书ID添加到购物车里面</description> <display-name>将图书添加到购物车</display-name> <servlet-name>CartServlet</servlet-name> <servlet-class>com.Bookinfo.Servlet.util.CartServlet</servlet-class> </servlet> <servlet> <description>根据图书ID将图书信息添加到购物车里面</description> <display-name>将图书全部信息添加到购物车</display-name> <servlet-name>CartMessageServlet</servlet-name> <servlet-class>com.Bookinfo.Servlet.util.CartMessageServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>loginuser</servlet-name> <url-pattern>/loginUser</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>CartServlet</servlet-name> <url-pattern>/CartServlet</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>CartMessageServlet</servlet-name> <url-pattern>/CartMessageServlet</url-pattern> </servlet-mapping> </web-app>
相关推荐
6. Protection Features:JW5033T 具有多种保护功能,包括短路保护、热保护、电流逃逸保护和输入欠压锁定保护等,这使其能够确保系统的安全和可靠性。 7. Package:JW5033T 采用 TSOT23-6 封装,提供紧凑的解决方案...
杰华特 JW5306的规格书JW5352&JW5352M_Datasheet_R0.21_EN_20211213 for 九联.pdf
在当今追求高效能和紧凑设计的电源管理领域,JW5033S作为一种电流模式单片式降压电压转换器,已经脱颖而出,凭借其先进的设计和功能,满足了现代电子设备对电源转换器的各种需求。该转换器能够覆盖3.7V至18V的宽输入...
在使用Jw_win时,用户可以利用其内置的图形用户界面(GUI)进行直观操作,包括直线、曲线、弧形等基本几何对象的绘制,以及尺寸标注、文本注释等功能。此外,软件可能还支持图层管理、对象捕捉、块和外部参照,这些...
官方JW Player通常需要购买许可证才能用于商业项目。使用已去水印和右键禁用的版本可能违反JW Player的条款和条件。因此,在实际应用中,应确保遵循合法途径,尊重软件开发者的工作并遵守相关法律法规,以免引起法律...
JW Player 3.2具备智能的自适应流功能,可根据网络状况动态调整视频质量。源码中展示了如何监控网络状态,优化缓冲策略,提高播放体验。 9. **错误处理与调试** 源码中包含了详细的错误处理机制,确保在遇到问题...
标题“JW1991C pdf文档整理.zip”表明这是一个包含PDF文档的压缩文件,其中的内容可能与编号为“JW1991C”的某个项目、课程或者研究有关。这种类型的文件通常用于组织和共享大量的文本资料,比如教程、研究报告、...
总结来说,JW FLV Player是在线视频播放领域的经典工具,其易用性和强大的功能使其在一段时间内成为了许多网站的首选。然而,随着技术的进步,开发者需要关注并考虑过渡到支持HTML5的播放解决方案,以保持与现代...
本文将深入探讨JW Player JavaScript API的核心概念、主要功能以及常见用法。 1. **核心概念** - **JW Player实例**:在网页中,首先需要创建一个JW Player实例。这通常是通过调用`jwplayer(id)`函数完成的,其中`...
**JW Player功能特性** 1. **跨平台兼容性**:JW Player不仅支持各种现代浏览器,如Chrome、Firefox、Safari、Edge,还能够兼容不同的操作系统,包括Windows、Mac和Linux。 2. **多格式支持**:除了FLV,JW Player还...
此外,JW5026还有集成内部补偿、软启动和输出短路保护等附加功能。 JW5026的典型应用电路设计中,需要特别注意其外围电路的布局,从而确保电路板的性能。测试结果表明,基于JW5026的电源设计电路在不同工况下,例如...
为了进一步保护设备,在故障条件下,JW3651还提供了恒流控制功能,有效防止过压情况的发生。 JW3651的稳定性和安全性是通过其内部集成的多种保护机制来保证的。其内置的欠压锁定功能可以确保设备在输入电压不足时...
JW FLV Media Player是一款广泛应用的开源FLV媒体播放器,它以其强大的功能和灵活的自定义性深受开发者喜爱。本篇文章将深入探讨该播放器的核心特性,以及如何通过提供的FLA文件进行界面定制,以满足不同项目的需求...
**jw_flv_player 3.12**是一款强大的Flash FLV视频播放器,它以其易用性和功能丰富性在Web开发中广受欢迎。这款播放器版本3.12是其发展过程中的一个重要里程碑,提供了许多改进和优化,旨在提升用户体验和开发者的...
JW7700A是一种专为反激式变换器设计的同步整流芯片,具有以下特点和应用: 1. 集成40V耐压、16mΩ导通电阻的功率MOSFET,可替代肖特基二极管以实现更高效率。其整流效率的提升主要得益于MOSFET的低导通电阻特性。 ...
这个脚本可能包含了处理用户输入、数据库交互、页面逻辑等功能,是JW页面工厂实现功能的关键部分。 "site" 目录可能包含了预设的网站模板或者样例页面,用户可以直接使用或作为自定义设计的基础。这些模板可能包含...
同时,该芯片具有过流保护、热保护、启动电流run-away保护和输入低电压锁定等功能。 评估板 该评估板提供了一个完整的解决方案,仅需要最少的外部组件。该板可以在VIN=5V、VIN=12V和VIN=18V三个输入电压条件下工作...
3.0V to 42V Operating Input Range 1.4A, 65V Internal DMOS Power Switch Up to 430KHz Operating Frequency Low Quiescent Current Boundary Mode Operation at Heavy Load Burst Mode Operation at Light ...
很抱歉,根据您提供的信息,"jw000000.rar" 和 "jw.rar" 是两个压缩文件的名称,而"jw"是它们的标签,但没有提供具体的压缩包内容或相关的IT知识点。文件名称列表中只给出了"11479",这似乎是一个数字或者错误的...