diff --git a/.myhibernatedata b/.myhibernatedata index 43b3612..8f24698 100644 --- a/.myhibernatedata +++ b/.myhibernatedata @@ -1,7 +1,7 @@ #MyEclipse Hibernate Properties -#Fri Jan 03 19:00:56 CST 2020 +#Sat Jan 04 15:25:24 CST 2020 sessionFactoryName= -genBasicCompId=true +genBasicCompId=false profile= daoSFId= version=3.3 @@ -11,7 +11,7 @@ reStrategyClass= detectO2O=false springDaoFile= useJavaTypes=true -keyGenerator=native +keyGenerator= libInstallFolder=WebRoot/WEB-INF/lib addLibs2Project=true genVersionTag=false diff --git a/1.jsp b/1.jsp deleted file mode 100644 index 802a43b..0000000 --- a/1.jsp +++ /dev/null @@ -1,249 +0,0 @@ -<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> -<%@ taglib prefix="s" uri="/struts-tags" %> -<% -String path = request.getContextPath(); -String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; -%> - - - - - - - 登录|注册 - - - - - - - - - - - - - - - - - - - -
-
- -
- - 登录 - - 注册 - -
- - -
-
-
- 登录| - - 注册 -
- - - - - - - - -
-
- - -
-

注册

-

忘记密码

-
- -
-

———其他登录方式 ———

- -
-
- - - - diff --git a/WebRoot/WEB-INF/classes/HelloServlet.class b/WebRoot/WEB-INF/classes/HelloServlet.class new file mode 100644 index 0000000..ca8d98e Binary files /dev/null and b/WebRoot/WEB-INF/classes/HelloServlet.class differ diff --git a/WebRoot/WEB-INF/classes/RegisterAction.class b/WebRoot/WEB-INF/classes/RegisterAction.class index 0046c6c..d1f925e 100644 Binary files a/WebRoot/WEB-INF/classes/RegisterAction.class and b/WebRoot/WEB-INF/classes/RegisterAction.class differ diff --git a/WebRoot/WEB-INF/classes/SubmitQgAction.class b/WebRoot/WEB-INF/classes/SubmitQgAction.class new file mode 100644 index 0000000..e0efc89 Binary files /dev/null and b/WebRoot/WEB-INF/classes/SubmitQgAction.class differ diff --git a/WebRoot/WEB-INF/classes/SubmitXzAction.class b/WebRoot/WEB-INF/classes/SubmitXzAction.class index fa26cf0..fded31d 100644 Binary files a/WebRoot/WEB-INF/classes/SubmitXzAction.class and b/WebRoot/WEB-INF/classes/SubmitXzAction.class differ diff --git a/WebRoot/WEB-INF/classes/XzListServlet.class b/WebRoot/WEB-INF/classes/XzListServlet.class new file mode 100644 index 0000000..00a79c6 Binary files /dev/null and b/WebRoot/WEB-INF/classes/XzListServlet.class differ diff --git a/WebRoot/WEB-INF/classes/com/AbstractQg.class b/WebRoot/WEB-INF/classes/com/AbstractQg.class new file mode 100644 index 0000000..8262c20 Binary files /dev/null and b/WebRoot/WEB-INF/classes/com/AbstractQg.class differ diff --git a/WebRoot/WEB-INF/classes/com/AbstractXz.class b/WebRoot/WEB-INF/classes/com/AbstractXz.class index 62ec338..0e1661c 100644 Binary files a/WebRoot/WEB-INF/classes/com/AbstractXz.class and b/WebRoot/WEB-INF/classes/com/AbstractXz.class differ diff --git a/WebRoot/WEB-INF/classes/com/Qg.class b/WebRoot/WEB-INF/classes/com/Qg.class new file mode 100644 index 0000000..fb170bb Binary files /dev/null and b/WebRoot/WEB-INF/classes/com/Qg.class differ diff --git a/WebRoot/WEB-INF/classes/com/Qg.hbm.xml b/WebRoot/WEB-INF/classes/com/Qg.hbm.xml new file mode 100644 index 0000000..37debbb --- /dev/null +++ b/WebRoot/WEB-INF/classes/com/Qg.hbm.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WebRoot/WEB-INF/classes/com/Xz.class b/WebRoot/WEB-INF/classes/com/Xz.class index 011bb29..37c8a44 100644 Binary files a/WebRoot/WEB-INF/classes/com/Xz.class and b/WebRoot/WEB-INF/classes/com/Xz.class differ diff --git a/WebRoot/WEB-INF/classes/com/Xz.hbm.xml b/WebRoot/WEB-INF/classes/com/Xz.hbm.xml index e62e863..9c8ff51 100644 --- a/WebRoot/WEB-INF/classes/com/Xz.hbm.xml +++ b/WebRoot/WEB-INF/classes/com/Xz.hbm.xml @@ -11,13 +11,13 @@ - + - - + + - + diff --git a/WebRoot/WEB-INF/classes/hibernate.cfg.xml b/WebRoot/WEB-INF/classes/hibernate.cfg.xml index 0bf69d0..bd907a2 100644 --- a/WebRoot/WEB-INF/classes/hibernate.cfg.xml +++ b/WebRoot/WEB-INF/classes/hibernate.cfg.xml @@ -24,6 +24,7 @@ true + diff --git a/WebRoot/WEB-INF/classes/struts.xml b/WebRoot/WEB-INF/classes/struts.xml index 60d93cd..4e55a43 100644 --- a/WebRoot/WEB-INF/classes/struts.xml +++ b/WebRoot/WEB-INF/classes/struts.xml @@ -23,6 +23,10 @@ /welcome.jsp /success.jsp + +/welcome.jsp +/success.jsp + diff --git a/WebRoot/WEB-INF/web.xml b/WebRoot/WEB-INF/web.xml index 001cb6a..90033a2 100644 --- a/WebRoot/WEB-INF/web.xml +++ b/WebRoot/WEB-INF/web.xml @@ -5,6 +5,22 @@ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> + + + This is the description of my J2EE component + This is the display name of my J2EE component + HelloServlet + HelloServlet + + + + + + HelloServlet + /HelloServlet + + + index.jsp @@ -16,5 +32,13 @@ struts2 - /* - + *.action + + + struts2 + *.jsp + + + + + diff --git a/WebRoot/button.jsp b/WebRoot/button.jsp new file mode 100644 index 0000000..28e5a6c --- /dev/null +++ b/WebRoot/button.jsp @@ -0,0 +1,337 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/WebRoot/ckxz.jsp b/WebRoot/ckxz.jsp new file mode 100644 index 0000000..11be7a4 --- /dev/null +++ b/WebRoot/ckxz.jsp @@ -0,0 +1,626 @@ +<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> +<% +String path = request.getContextPath(); +String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + My JSP 'buy.jsp' starting page + + + + + + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + + +
+
+
+ +
+

查看求购

+

逛市场可以赚大钱哦~

+
+
+
+ +
+

发布闲置

+

逛市场可以赚大钱哦~

+
+
+
+ + + + + + + + + + + +
+
+ + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + +
+ +
    +<%! int id[]={0,1,2,3,4,5,6,7,8,9}; %> + +<% + + for(int i=0;i + +
  • +
    + <%=id[i]%> +
    +
  • + +<% +} + + %> +
+
+ + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + diff --git a/WebRoot/fbqg.jsp b/WebRoot/fbqg.jsp index 07a63ae..3f78a17 100644 --- a/WebRoot/fbqg.jsp +++ b/WebRoot/fbqg.jsp @@ -1,4 +1,6 @@ <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> +<%@ taglib prefix="s" uri="/struts-tags" %> + <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; @@ -95,7 +97,7 @@ width:800px;
-
+ @@ -104,8 +106,8 @@ width:800px;
-
- +
+
@@ -115,9 +117,8 @@ width:800px; 简介
- - -
+ +
@@ -126,8 +127,8 @@ width:800px; 可接受价格
- -
+ + @@ -137,8 +138,8 @@ width:800px; 微信号
- -
+ +
@@ -147,8 +148,8 @@ width:800px; 手机号
- -
+ +
@@ -157,7 +158,7 @@ width:800px; QQ号
- +
@@ -207,22 +208,14 @@ function compress() { } - - - - - - - - - +
- +
diff --git a/WebRoot/fbxz.jsp b/WebRoot/fbxz.jsp index 87aa6f7..85441bd 100644 --- a/WebRoot/fbxz.jsp +++ b/WebRoot/fbxz.jsp @@ -96,8 +96,8 @@ width:800px; ————发布闲置————
-
- +
+ @@ -109,7 +109,7 @@ width:800px; 标题
- +
@@ -120,7 +120,7 @@ width:800px;
- +
@@ -184,17 +184,163 @@ width:800px; - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pagebean/WebRoot/WEB-INF/classes/dao/ProductsDAO.class b/pagebean/WebRoot/WEB-INF/classes/dao/ProductsDAO.class new file mode 100644 index 0000000..793c8ab Binary files /dev/null and b/pagebean/WebRoot/WEB-INF/classes/dao/ProductsDAO.class differ diff --git a/pagebean/WebRoot/WEB-INF/classes/dao/ProductsId.class b/pagebean/WebRoot/WEB-INF/classes/dao/ProductsId.class new file mode 100644 index 0000000..f144d59 Binary files /dev/null and b/pagebean/WebRoot/WEB-INF/classes/dao/ProductsId.class differ diff --git a/pagebean/WebRoot/WEB-INF/classes/hibernate.cfg.xml b/pagebean/WebRoot/WEB-INF/classes/hibernate.cfg.xml new file mode 100644 index 0000000..d970cc4 --- /dev/null +++ b/pagebean/WebRoot/WEB-INF/classes/hibernate.cfg.xml @@ -0,0 +1,26 @@ + + + + + + + + + org.hibernate.dialect.MySQLDialect + + + jdbc:mysql://localhost:3306/myday + + root + mysql123 + + com.mysql.jdbc.Driver + + myday + + + + + \ No newline at end of file diff --git a/pagebean/WebRoot/WEB-INF/classes/model/PageBean.class b/pagebean/WebRoot/WEB-INF/classes/model/PageBean.class new file mode 100644 index 0000000..0e2d83e Binary files /dev/null and b/pagebean/WebRoot/WEB-INF/classes/model/PageBean.class differ diff --git a/pagebean/WebRoot/WEB-INF/classes/model/Product.class b/pagebean/WebRoot/WEB-INF/classes/model/Product.class new file mode 100644 index 0000000..daf6188 Binary files /dev/null and b/pagebean/WebRoot/WEB-INF/classes/model/Product.class differ diff --git a/pagebean/WebRoot/WEB-INF/classes/service/ProductService.class b/pagebean/WebRoot/WEB-INF/classes/service/ProductService.class new file mode 100644 index 0000000..93fcefb Binary files /dev/null and b/pagebean/WebRoot/WEB-INF/classes/service/ProductService.class differ diff --git a/pagebean/WebRoot/WEB-INF/lib/mysql-connector-java-5.1.47.jar b/pagebean/WebRoot/WEB-INF/lib/mysql-connector-java-5.1.47.jar new file mode 100644 index 0000000..f3398ed Binary files /dev/null and b/pagebean/WebRoot/WEB-INF/lib/mysql-connector-java-5.1.47.jar differ diff --git a/pagebean/WebRoot/WEB-INF/web.xml b/pagebean/WebRoot/WEB-INF/web.xml new file mode 100644 index 0000000..5b6f684 --- /dev/null +++ b/pagebean/WebRoot/WEB-INF/web.xml @@ -0,0 +1,11 @@ + + + + + index.jsp + + diff --git a/pagebean/WebRoot/index.jsp b/pagebean/WebRoot/index.jsp new file mode 100644 index 0000000..19ce291 --- /dev/null +++ b/pagebean/WebRoot/index.jsp @@ -0,0 +1,26 @@ +<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> +<% +String path = request.getContextPath(); +String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + My JSP 'index.jsp' starting page + + + + + + + + + + This is my JSP page.
+ + diff --git a/pagebean/WebRoot/page.jsp b/pagebean/WebRoot/page.jsp new file mode 100644 index 0000000..80f868c --- /dev/null +++ b/pagebean/WebRoot/page.jsp @@ -0,0 +1,42 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> + + + + +Insert title here + + + <%-- 构建分页导航 --%> + 共有${requestScope.pageBean.totalRecord}条信息,共${requestScope.pageBean.totalPage }页,当前为${requestScope.pageBean.pageNum}页 +
+ + + + 首页 + 上一页 + + + + + + + + ${i} + + + ${i} + + + + + + 下一页 + 末页 + + + <%--尾页 --%> + 尾页 + + \ No newline at end of file diff --git a/pagebean/src/action/ProductAction.java b/pagebean/src/action/ProductAction.java new file mode 100644 index 0000000..b612e89 --- /dev/null +++ b/pagebean/src/action/ProductAction.java @@ -0,0 +1,31 @@ +package action; +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import model.PageBean; + +import service.ProductService; + + +public class ProductAction { + + + + public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + + int pageNum = Integer.valueOf(request.getParameter("pageNum")); + int pageSize=10; + ProductService ps = new ProductService(); + //ȡһPageBean + PageBean pb = ps.showAllProductWithPage(pageNum, pageSize); + + //pbrequest + request.setAttribute("pageBean",pb); + request.getRequestDispatcher("/page.jsp").forward(request,response); + } + + +} diff --git a/pagebean/src/dao/AbstractProducts.java b/pagebean/src/dao/AbstractProducts.java new file mode 100644 index 0000000..3ba6793 --- /dev/null +++ b/pagebean/src/dao/AbstractProducts.java @@ -0,0 +1,35 @@ +package dao; + +/** + * AbstractProducts entity provides the base persistence definition of the + * Products entity. @author MyEclipse Persistence Tools + */ + +public abstract class AbstractProducts implements java.io.Serializable { + + // Fields + + private ProductsId id; + + // Constructors + + /** default constructor */ + public AbstractProducts() { + } + + /** full constructor */ + public AbstractProducts(ProductsId id) { + this.id = id; + } + + // Property accessors + + public ProductsId getId() { + return this.id; + } + + public void setId(ProductsId id) { + this.id = id; + } + +} \ No newline at end of file diff --git a/pagebean/src/dao/AbstractProductsId.java b/pagebean/src/dao/AbstractProductsId.java new file mode 100644 index 0000000..8150e8d --- /dev/null +++ b/pagebean/src/dao/AbstractProductsId.java @@ -0,0 +1,173 @@ +package dao; + +/** + * AbstractProductsId entity provides the base persistence definition of the + * ProductsId entity. @author MyEclipse Persistence Tools + */ + +public abstract class AbstractProductsId implements java.io.Serializable { + + // Fields + + private Integer proId; + private Integer userId; + private String proName; + private String contact; + private Float price; + private Float oprice; + private Integer type; + private Integer classifyId; + + // Constructors + + /** default constructor */ + public AbstractProductsId() { + } + + /** minimal constructor */ + public AbstractProductsId(Integer proId, Integer userId) { + this.proId = proId; + this.userId = userId; + } + + /** full constructor */ + public AbstractProductsId(Integer proId, Integer userId, String proName, + String contact, Float price, Float oprice, Integer type, + Integer classifyId) { + this.proId = proId; + this.userId = userId; + this.proName = proName; + this.contact = contact; + this.price = price; + this.oprice = oprice; + this.type = type; + this.classifyId = classifyId; + } + + // Property accessors + + public Integer getProId() { + return this.proId; + } + + public void setProId(Integer proId) { + this.proId = proId; + } + + public Integer getUserId() { + return this.userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } + + public String getProName() { + return this.proName; + } + + public void setProName(String proName) { + this.proName = proName; + } + + public String getContact() { + return this.contact; + } + + public void setContact(String contact) { + this.contact = contact; + } + + public Float getPrice() { + return this.price; + } + + public void setPrice(Float price) { + this.price = price; + } + + public Float getOprice() { + return this.oprice; + } + + public void setOprice(Float oprice) { + this.oprice = oprice; + } + + public Integer getType() { + return this.type; + } + + public void setType(Integer type) { + this.type = type; + } + + public Integer getClassifyId() { + return this.classifyId; + } + + public void setClassifyId(Integer classifyId) { + this.classifyId = classifyId; + } + + public boolean equals(Object other) { + if ((this == other)) + return true; + if ((other == null)) + return false; + if (!(other instanceof AbstractProductsId)) + return false; + AbstractProductsId castOther = (AbstractProductsId) other; + + return ((this.getProId() == castOther.getProId()) || (this.getProId() != null + && castOther.getProId() != null && this.getProId().equals( + castOther.getProId()))) + && ((this.getUserId() == castOther.getUserId()) || (this + .getUserId() != null && castOther.getUserId() != null && this + .getUserId().equals(castOther.getUserId()))) + && ((this.getProName() == castOther.getProName()) || (this + .getProName() != null && castOther.getProName() != null && this + .getProName().equals(castOther.getProName()))) + && ((this.getContact() == castOther.getContact()) || (this + .getContact() != null && castOther.getContact() != null && this + .getContact().equals(castOther.getContact()))) + && ((this.getPrice() == castOther.getPrice()) || (this + .getPrice() != null && castOther.getPrice() != null && this + .getPrice().equals(castOther.getPrice()))) + && ((this.getOprice() == castOther.getOprice()) || (this + .getOprice() != null && castOther.getOprice() != null && this + .getOprice().equals(castOther.getOprice()))) + && ((this.getType() == castOther.getType()) || (this.getType() != null + && castOther.getType() != null && this.getType() + .equals(castOther.getType()))) + && ((this.getClassifyId() == castOther.getClassifyId()) || (this + .getClassifyId() != null + && castOther.getClassifyId() != null && this + .getClassifyId().equals(castOther.getClassifyId()))); + } + + public int hashCode() { + int result = 17; + + result = 37 * result + + (getProId() == null ? 0 : this.getProId().hashCode()); + result = 37 * result + + (getUserId() == null ? 0 : this.getUserId().hashCode()); + result = 37 * result + + (getProName() == null ? 0 : this.getProName().hashCode()); + result = 37 * result + + (getContact() == null ? 0 : this.getContact().hashCode()); + result = 37 * result + + (getPrice() == null ? 0 : this.getPrice().hashCode()); + result = 37 * result + + (getOprice() == null ? 0 : this.getOprice().hashCode()); + result = 37 * result + + (getType() == null ? 0 : this.getType().hashCode()); + result = 37 + * result + + (getClassifyId() == null ? 0 : this.getClassifyId() + .hashCode()); + return result; + } + +} \ No newline at end of file diff --git a/pagebean/src/dao/BaseHibernateDAO.java b/pagebean/src/dao/BaseHibernateDAO.java new file mode 100644 index 0000000..40bc925 --- /dev/null +++ b/pagebean/src/dao/BaseHibernateDAO.java @@ -0,0 +1,16 @@ +package dao; + +import org.hibernate.Session; + + +/** + * Data access object (DAO) for domain model + * @author MyEclipse Persistence Tools + */ +public class BaseHibernateDAO implements IBaseHibernateDAO { + + public Session getSession() { + return HibernateSessionFactory.getSession(); + } + +} \ No newline at end of file diff --git a/pagebean/src/dao/HibernateSessionFactory.java b/pagebean/src/dao/HibernateSessionFactory.java new file mode 100644 index 0000000..a2d103a --- /dev/null +++ b/pagebean/src/dao/HibernateSessionFactory.java @@ -0,0 +1,118 @@ +package dao; + +import org.hibernate.HibernateException; +import org.hibernate.Session; +import org.hibernate.cfg.Configuration; + +/** + * Configures and provides access to Hibernate sessions, tied to the + * current thread of execution. Follows the Thread Local Session + * pattern, see {@link http://hibernate.org/42.html }. + */ +public class HibernateSessionFactory { + + /** + * Location of hibernate.cfg.xml file. + * Location should be on the classpath as Hibernate uses + * #resourceAsStream style lookup for its configuration file. + * The default classpath location of the hibernate config file is + * in the default package. Use #setConfigFile() to update + * the location of the configuration file for the current session. + */ + private static String CONFIG_FILE_LOCATION = "/hibernate.cfg.xml"; + private static final ThreadLocal threadLocal = new ThreadLocal(); + private static Configuration configuration = new Configuration(); + private static org.hibernate.SessionFactory sessionFactory; + private static String configFile = CONFIG_FILE_LOCATION; + + static { + try { + configuration.configure(configFile); + sessionFactory = configuration.buildSessionFactory(); + } catch (Exception e) { + System.err + .println("%%%% Error Creating SessionFactory %%%%"); + e.printStackTrace(); + } + } + private HibernateSessionFactory() { + } + + /** + * Returns the ThreadLocal Session instance. Lazy initialize + * the SessionFactory if needed. + * + * @return Session + * @throws HibernateException + */ + public static Session getSession() throws HibernateException { + Session session = (Session) threadLocal.get(); + + if (session == null || !session.isOpen()) { + if (sessionFactory == null) { + rebuildSessionFactory(); + } + session = (sessionFactory != null) ? sessionFactory.openSession() + : null; + threadLocal.set(session); + } + + return session; + } + + /** + * Rebuild hibernate session factory + * + */ + public static void rebuildSessionFactory() { + try { + configuration.configure(configFile); + sessionFactory = configuration.buildSessionFactory(); + } catch (Exception e) { + System.err + .println("%%%% Error Creating SessionFactory %%%%"); + e.printStackTrace(); + } + } + + /** + * Close the single hibernate session instance. + * + * @throws HibernateException + */ + public static void closeSession() throws HibernateException { + Session session = (Session) threadLocal.get(); + threadLocal.set(null); + + if (session != null) { + session.close(); + } + } + + /** + * return session factory + * + */ + public static org.hibernate.SessionFactory getSessionFactory() { + return sessionFactory; + } + + /** + * return session factory + * + * session factory will be rebuilded in the next call + */ + public static void setConfigFile(String configFile) { + HibernateSessionFactory.configFile = configFile; + sessionFactory = null; + } + + /** + * return hibernate configuration + * + */ + public static Configuration getConfiguration() { + return configuration; + } + +} \ No newline at end of file diff --git a/pagebean/src/dao/IBaseHibernateDAO.java b/pagebean/src/dao/IBaseHibernateDAO.java new file mode 100644 index 0000000..ccc03cf --- /dev/null +++ b/pagebean/src/dao/IBaseHibernateDAO.java @@ -0,0 +1,12 @@ +package dao; + +import org.hibernate.Session; + + +/** + * Data access interface for domain model + * @author MyEclipse Persistence Tools + */ +public interface IBaseHibernateDAO { + public Session getSession(); +} \ No newline at end of file diff --git a/pagebean/src/dao/Products.hbm.xml b/pagebean/src/dao/Products.hbm.xml new file mode 100644 index 0000000..acce55c --- /dev/null +++ b/pagebean/src/dao/Products.hbm.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pagebean/src/dao/Products.java b/pagebean/src/dao/Products.java new file mode 100644 index 0000000..394c9bf --- /dev/null +++ b/pagebean/src/dao/Products.java @@ -0,0 +1,19 @@ +package dao; + +/** + * Products entity. @author MyEclipse Persistence Tools + */ +public class Products extends AbstractProducts implements java.io.Serializable { + + // Constructors + + /** default constructor */ + public Products() { + } + + /** full constructor */ + public Products(ProductsId id) { + super(id); + } + +} diff --git a/pagebean/src/dao/ProductsDAO.java b/pagebean/src/dao/ProductsDAO.java new file mode 100644 index 0000000..60f9d29 --- /dev/null +++ b/pagebean/src/dao/ProductsDAO.java @@ -0,0 +1,135 @@ +package dao; + +import java.util.List; +import org.hibernate.LockMode; +import org.hibernate.Query; +import org.hibernate.criterion.Example; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * A data access object (DAO) providing persistence and search support for + * Products entities. Transaction control of the save(), update() and delete() + * operations can directly support Spring container-managed transactions or they + * can be augmented to handle user-managed Spring transactions. Each of these + * methods provides additional information for how to configure it for the + * desired type of transaction control. + * + * @see hib.Products + * @author MyEclipse Persistence Tools + */ + +public class ProductsDAO extends BaseHibernateDAO { + private static final Logger log = LoggerFactory + .getLogger(ProductsDAO.class); + + // property constants + + public void save(Products transientInstance) { + log.debug("saving Products instance"); + try { + getSession().save(transientInstance); + log.debug("save successful"); + } catch (RuntimeException re) { + log.error("save failed", re); + throw re; + } + } + + public void delete(Products persistentInstance) { + log.debug("deleting Products instance"); + try { + getSession().delete(persistentInstance); + log.debug("delete successful"); + } catch (RuntimeException re) { + log.error("delete failed", re); + throw re; + } + } + + public Products findById(dao.ProductsId id) { + log.debug("getting Products instance with id: " + id); + try { + Products instance = (Products) getSession().get("hib.Products", id); + return instance; + } catch (RuntimeException re) { + log.error("get failed", re); + throw re; + } + } + + public List findByExample(Products instance) { + log.debug("finding Products instance by example"); + try { + List results = getSession().createCriteria("hib.Products") + .add(Example.create(instance)).list(); + log.debug("find by example successful, result size: " + + results.size()); + return results; + } catch (RuntimeException re) { + log.error("find by example failed", re); + throw re; + } + } + + public List findByProperty(String propertyName, Object value) { + log.debug("finding Products instance with property: " + propertyName + + ", value: " + value); + try { + String queryString = "from Products as model where model." + + propertyName + "= ?"; + Query queryObject = getSession().createQuery(queryString); + queryObject.setParameter(0, value); + return queryObject.list(); + } catch (RuntimeException re) { + log.error("find by property name failed", re); + throw re; + } + } + + public List findAll() { + log.debug("finding all Products instances"); + try { + String queryString = "from Products"; + Query queryObject = getSession().createQuery(queryString); + return queryObject.list(); + } catch (RuntimeException re) { + log.error("find all failed", re); + throw re; + } + } + + public Products merge(Products detachedInstance) { + log.debug("merging Products instance"); + try { + Products result = (Products) getSession().merge(detachedInstance); + log.debug("merge successful"); + return result; + } catch (RuntimeException re) { + log.error("merge failed", re); + throw re; + } + } + + public void attachDirty(Products instance) { + log.debug("attaching dirty Products instance"); + try { + getSession().saveOrUpdate(instance); + log.debug("attach successful"); + } catch (RuntimeException re) { + log.error("attach failed", re); + throw re; + } + } + + public void attachClean(Products instance) { + log.debug("attaching clean Products instance"); + try { + getSession().lock(instance, LockMode.NONE); + log.debug("attach successful"); + } catch (RuntimeException re) { + log.error("attach failed", re); + throw re; + } + } +} \ No newline at end of file diff --git a/pagebean/src/dao/ProductsId.java b/pagebean/src/dao/ProductsId.java new file mode 100644 index 0000000..bdf7b52 --- /dev/null +++ b/pagebean/src/dao/ProductsId.java @@ -0,0 +1,27 @@ +package dao; + +/** + * ProductsId entity. @author MyEclipse Persistence Tools + */ +public class ProductsId extends AbstractProductsId implements + java.io.Serializable { + + // Constructors + + /** default constructor */ + public ProductsId() { + } + + /** minimal constructor */ + public ProductsId(Integer proId, Integer userId) { + super(proId, userId); + } + + /** full constructor */ + public ProductsId(Integer proId, Integer userId, String proName, + String contact, Float price, Float oprice, Integer type, + Integer classifyId) { + super(proId, userId, proName, contact, price, oprice, type, classifyId); + } + +} diff --git a/pagebean/src/hibernate.cfg.xml b/pagebean/src/hibernate.cfg.xml new file mode 100644 index 0000000..d970cc4 --- /dev/null +++ b/pagebean/src/hibernate.cfg.xml @@ -0,0 +1,26 @@ + + + + + + + + + org.hibernate.dialect.MySQLDialect + + + jdbc:mysql://localhost:3306/myday + + root + mysql123 + + com.mysql.jdbc.Driver + + myday + + + + + \ No newline at end of file diff --git a/pagebean/src/model/PageBean.java b/pagebean/src/model/PageBean.java new file mode 100644 index 0000000..d3d4c7d --- /dev/null +++ b/pagebean/src/model/PageBean.java @@ -0,0 +1,129 @@ +package model; +import java.util.List; + + +public class PageBean { + private int pageNum; //ǰҳ,DZߴ + private int pageSize; //ÿҳʾ + private int totalRecord; //ܵļ¼ѯݿõ + + public int getPageNum() { + return pageNum; + } + + public void setPageNum(int pageNum) { + this.pageNum = pageNum; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getTotalRecord() { + return totalRecord; + } + + public void setTotalRecord(int totalRecord) { + this.totalRecord = totalRecord; + } + + public int getTotalPage() { + return totalPage; + } + + public void setTotalPage(int totalPage) { + this.totalPage = totalPage; + } + + public int getStartIndex() { + return startIndex; + } + + public void setStartIndex(int startIndex) { + this.startIndex = startIndex; + } + + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + + public int getStart() { + return start; + } + + public void setStart(int start) { + this.start = start; + } + + public int getEnd() { + return end; + } + + public void setEnd(int end) { + this.end = end; + } + + //Ҫ + private int totalPage; //ҳͨtotalRecordpageSizeԵ + //ʼҲݿҪӵڼݿʼãstartIndexpageSize + //֪limitݣܻÿҳҪʾ + private int startIndex; + + //ÿҳҪʾݷlist + private List list; + + //ҳʾҳ,ҳʾ12345ҳstartΪ1endΪ5Ҳ + private int start; + private int end; + + //ͨpageNumpageSizetotalRecordtatalPagestartIndex + //췽нpageNumpageSizetotalRecord + public PageBean(int pageNum,int pageSize,int totalRecord) { + this.pageNum = pageNum; + this.pageSize = pageSize; + this.totalRecord = totalRecord; + + //totalPage ҳ + if(totalRecord%pageSize==0){ + //˵ÿҳʾpageSizeݣûжһҳҪʾpageSizeݵ + this.totalPage = totalRecord / pageSize; + }else{ + //Ҫڼһҳʾݡ + this.totalPage = totalRecord / pageSize +1; + } + //ʼ + this.startIndex = (pageNum-1)*pageSize ; + //ʾ5ҳ + this.start = 1; + this.end = 5; + //ʾҳ㷨 + + if(totalPage <=5){ + //ҳС5ôendΪҳֵˡ + this.end = this.totalPage; + }else{ + //ҳ5ôҪݵǰǵڼҳжstartendΪˣ + this.start = pageNum - 2; + this.end = pageNum + 2; + + if(start <= 0){ + //統ǰҳǵ1ҳߵ2ҳôͲ + this.start = 1; + this.end = 5; + } + if(end > this.totalPage){ + //統ǰҳǵ2ҳһҳҲͬ + this.end = totalPage; + this.start = end - 5; + } + } + } +} diff --git a/pagebean/src/model/Product.java b/pagebean/src/model/Product.java new file mode 100644 index 0000000..45d18af --- /dev/null +++ b/pagebean/src/model/Product.java @@ -0,0 +1,56 @@ +package model; + + +public class Product { + private int proId; + private int userId; + private String proName; //Ʒ + private String contact; //ϵʽ + private float price; //ת + private float oprice; //ԭ + private int classifyId; // + private int type; + + public int getProId() { + return proId; + } + public void setProId(int proId) { + this.proId = proId; + } + public int getUserId() { + return userId; + } + public void setUserId(int userId) { + this.userId = userId; + } + public String getProName() { + return proName; + } + public void setProName(String proName) { + this.proName = proName; + } + public String getContact() { + return contact; + } + public void setContact(String contact) { + this.contact = contact; + } + public float getPrice() { + return price; + } + public void setPrice(float price) { + this.price = price; + } + public float getOprice() { + return oprice; + } + public void setOprice(float oprice) { + this.oprice = oprice; + } + public int getType() { + return type; + } + public void setType(int type) { + this.type = type; + } +} diff --git a/pagebean/src/service/ProductService.java b/pagebean/src/service/ProductService.java new file mode 100644 index 0000000..538a0d5 --- /dev/null +++ b/pagebean/src/service/ProductService.java @@ -0,0 +1,27 @@ +package service; +import dao.ProductsDAO; + +import java.util.List; + +import model.PageBean; +import model.Product; + + +public class ProductService { + + + @SuppressWarnings("unchecked") + public PageBean showAllProductWithPage(int pageNum,int pageSize){ + ProductsDAO pro=new ProductsDAO(); + List allProduct = pro.findAll(); + int totalRecord = allProduct.size(); + + PageBean pb= new PageBean(pageNum,pageSize,totalRecord); + + int startIndex = pb.getStartIndex(); + +// pb.setList(ProductsDAO.findAll(startIndex,pageSize)); + pb.setList(pro.findAll()); + return pb; + } +} diff --git a/register.jsp b/register.jsp deleted file mode 100644 index 4d143ee..0000000 --- a/register.jsp +++ /dev/null @@ -1,18 +0,0 @@ -<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> -<%@ taglib prefix="s" uri="/struts-tags" %> - -用户注册 - -

注册一个新用户

- - - - - - - - - - - - diff --git a/src/HelloServlet.java b/src/HelloServlet.java new file mode 100644 index 0000000..3b0a586 --- /dev/null +++ b/src/HelloServlet.java @@ -0,0 +1,66 @@ + +import java.io.IOException; + +import java.io.PrintWriter; +import java.util.List; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.hibernate.HibernateException; +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.Transaction; + +import com.HibernateSessionFactory; +import com.Userinfo; +import com.Xz; + +import javax.persistence.Entity; +import javax.persistence.ManyToOne; + + +import com.opensymphony.xwork2.ActionSupport; + +public class HelloServlet extends HttpServlet { + public void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + listStudent( request, response); + + } + + public void listStudent(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + int xid=Integer.parseInt(request.getParameter("id")); + /* try{ + xid=Integer.parseInt(request.getParameter("id")); + }catch(NumberFormatException e){ + }*/ + Session session=HibernateSessionFactory.getSession(); + Transaction tx=null; + List xz=null; + try{ + tx=session.beginTransaction(); + Query query=session.createQuery("FROM Xz xz where xz.id=:xid"); + query.setParameter("xid", Integer.parseInt(request.getParameter("id"))); + xz=query.list(); + tx.commit(); + }catch(HibernateException e){ + if(tx!=null) tx.rollback(); + e.printStackTrace(); + }finally{ + session.close(); + } + if(xz!=null){ + request.setAttribute("xz", xz); + RequestDispatcher rd=request.getRequestDispatcher("xzxq.jsp"); + rd.forward(request, response); + } + } + + +} diff --git a/src/RegisterAction.java b/src/RegisterAction.java index 52e7313..91f672c 100644 --- a/src/RegisterAction.java +++ b/src/RegisterAction.java @@ -1,6 +1,8 @@ import java.util.List; + + import javax.persistence.Entity; import javax.persistence.ManyToOne; import org.hibernate.Transaction; diff --git a/src/SubmitQgAction.java b/src/SubmitQgAction.java new file mode 100644 index 0000000..f45e561 --- /dev/null +++ b/src/SubmitQgAction.java @@ -0,0 +1,47 @@ +import java.util.List; + +import javax.persistence.ManyToOne; + +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.Transaction; + +import com.HibernateSessionFactory; +import com.Qg; +import com.opensymphony.xwork2.ActionSupport; + + +public class SubmitQgAction extends ActionSupport { + @ManyToOne + private Qg qg; + + public Qg getQg() { + return qg; + } + + public void setQg(Qg qg) { + this.qg = qg; + } + + @Override + public String execute() throws Exception { + // TODO Auto-generated method stub + return SUCCESS; + } + public String submit() throws Exception{ + try{ + Session session=HibernateSessionFactory.getSession(); + Transaction tx=session.beginTransaction(); + session.save(qg); + tx.commit(); + return SUCCESS; + }catch(Exception e){ + e.printStackTrace(); + HibernateSessionFactory.getSession().close(); + return ERROR; + } + } + + + +} diff --git a/src/SubmitXzAction.java b/src/SubmitXzAction.java index 283fc3f..68e17e3 100644 --- a/src/SubmitXzAction.java +++ b/src/SubmitXzAction.java @@ -1,12 +1,20 @@ -import org.hibernate.Session; +import java.util.List; + + +import javax.persistence.Entity; +import javax.persistence.ManyToOne; import org.hibernate.Transaction; -import com.Xz; + +import org.hibernate.Query; +import org.hibernate.Session; import com.HibernateSessionFactory; +import com.Xz; import com.opensymphony.xwork2.ActionSupport; +@Entity public class SubmitXzAction extends ActionSupport { - + @ManyToOne private Xz xz; public Xz getXz() { @@ -22,19 +30,26 @@ public class SubmitXzAction extends ActionSupport { // TODO Auto-generated method stub return SUCCESS; } - public String submit() throws Exception{ try{ Session session=HibernateSessionFactory.getSession(); Transaction tx=session.beginTransaction(); + + session.save(xz); + System.out.println("555555555555555555555555555555555"); + tx.commit(); + return SUCCESS; }catch(Exception e){ + System.out.println("222222222222222222222222222222222222222222222222222222222222222222222222222222"); + e.printStackTrace(); HibernateSessionFactory.getSession().close(); return ERROR; } } - + + } diff --git a/src/XzListServlet.java b/src/XzListServlet.java new file mode 100644 index 0000000..1b4d948 --- /dev/null +++ b/src/XzListServlet.java @@ -0,0 +1,72 @@ +import java.io.IOException; + +import java.io.PrintWriter; +import java.io.IOException; + + + +import java.io.PrintWriter; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.RequestDispatcher; +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.mysql.jdbc.Connection; +//import com.sun.corba.se.pept.transport.Connection; + + +public class XzListServlet extends HttpServlet { + + /** + * Constructor of the object. + */ + public XzListServlet() { + super(); + } + + + + + + public void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + String uri=request.getRequestURI(); + if(uri.endsWith("/XzListServlet")){ + showProductDetails(request,response); + } + } + + + + private void showProductDetails(HttpServletRequest request,HttpServletResponse response) + throws IOException{ + response.setContentType("text/html;charset=UTF-8"); + PrintWriter out =response.getWriter(); + int productId=0; + try{ + productId=Integer.parseInt(request.getParameter("id")); + }catch(NumberFormatException e){ + out.print(productId); + } + + } + + + + + + + } + + + diff --git a/src/com/AbstractQg.java b/src/com/AbstractQg.java new file mode 100644 index 0000000..38aa6c0 --- /dev/null +++ b/src/com/AbstractQg.java @@ -0,0 +1,96 @@ +package com; + +/** + * AbstractQg entity provides the base persistence definition of the Qg entity. @author + * MyEclipse Persistence Tools + */ + +public abstract class AbstractQg implements java.io.Serializable { + + // Fields + + private Integer id; + private String title; + + private String miao; + private Integer price; + private String wx; + private String tel; + private String qq; + + // Constructors + + /** default constructor */ + public AbstractQg() { + } + + /** full constructor */ + public AbstractQg(String title,String miao, Integer price, String wx, String tel, + String qq) { + this.title=title; + this.miao = miao; + this.price = price; + this.wx = wx; + this.tel = tel; + this.qq = qq; + } + + // Property accessors + + public Integer getId() { + return this.id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getMiao() { + return this.miao; + } + + public void setMiao(String miao) { + this.miao = miao; + } + + public Integer getPrice() { + return this.price; + } + + public void setPrice(Integer price) { + this.price = price; + } + + public String getWx() { + return this.wx; + } + + public void setWx(String wx) { + this.wx = wx; + } + + public String getTel() { + return this.tel; + } + + public void setTel(String tel) { + this.tel = tel; + } + + public String getQq() { + return this.qq; + } + + public void setQq(String qq) { + this.qq = qq; + } + +} \ No newline at end of file diff --git a/src/com/AbstractXz.java b/src/com/AbstractXz.java index 72613c1..8a85dae 100644 --- a/src/com/AbstractXz.java +++ b/src/com/AbstractXz.java @@ -9,9 +9,9 @@ public abstract class AbstractXz implements java.io.Serializable { // Fields -// private Integer id; + private Integer id; private String title; - private String desc; + private String miao; private Integer sep; private Integer orp; private String postage; @@ -26,18 +26,18 @@ public abstract class AbstractXz implements java.io.Serializable { } /** minimal constructor */ - public AbstractXz(String title, Integer sep) { -// this.id=id; - + public AbstractXz(Integer id, String title, Integer sep) { + this.id = id; this.title = title; this.sep = sep; } /** full constructor */ - public AbstractXz(String title, String desc, Integer sep, Integer orp, - String postage, String wx, String tel, String qq) { + public AbstractXz(String title, String miao, Integer sep, + Integer orp, String postage, String wx, String tel, String qq) { + this.title = title; - this.desc = desc; + this.miao = miao; this.sep = sep; this.orp = orp; this.postage = postage; @@ -48,15 +48,18 @@ public abstract class AbstractXz implements java.io.Serializable { // Property accessors -/* public Integer getId() { + public Integer getId() { + System.out.println(this.id); return this.id; } public void setId(Integer id) { this.id = id; - }*/ + } public String getTitle() { + System.out.println(this.title); + return this.title; } @@ -64,15 +67,19 @@ public abstract class AbstractXz implements java.io.Serializable { this.title = title; } - public String getDesc() { - return this.desc; + public String getMiao() { + System.out.println(this.miao); + + return this.miao; } - public void setDesc(String desc) { - this.desc = desc; + public void setMiao(String miao) { + this.miao = miao; } public Integer getSep() { + System.out.println(this.sep); + return this.sep; } @@ -81,6 +88,8 @@ public abstract class AbstractXz implements java.io.Serializable { } public Integer getOrp() { + System.out.println(this.orp); + return this.orp; } @@ -89,6 +98,8 @@ public abstract class AbstractXz implements java.io.Serializable { } public String getPostage() { + System.out.println(this.postage); + return this.postage; } @@ -97,6 +108,8 @@ public abstract class AbstractXz implements java.io.Serializable { } public String getWx() { + System.out.println(this.wx); + return this.wx; } @@ -105,6 +118,8 @@ public abstract class AbstractXz implements java.io.Serializable { } public String getTel() { + System.out.println(this.tel); + return this.tel; } @@ -113,6 +128,8 @@ public abstract class AbstractXz implements java.io.Serializable { } public String getQq() { + System.out.println(this.qq); + return this.qq; } diff --git a/src/com/Qg.hbm.xml b/src/com/Qg.hbm.xml new file mode 100644 index 0000000..37debbb --- /dev/null +++ b/src/com/Qg.hbm.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/com/Qg.java b/src/com/Qg.java new file mode 100644 index 0000000..fe3317f --- /dev/null +++ b/src/com/Qg.java @@ -0,0 +1,19 @@ +package com; + +/** + * Qg entity. @author MyEclipse Persistence Tools + */ +public class Qg extends AbstractQg implements java.io.Serializable { + + // Constructors + + /** default constructor */ + public Qg() { + } + + /** full constructor */ + public Qg(String title,String miao, Integer price, String wx, String tel, String qq) { + super(title,miao, price, wx, tel, qq); + } + +} diff --git a/src/com/Xz.hbm.xml b/src/com/Xz.hbm.xml index e62e863..9c8ff51 100644 --- a/src/com/Xz.hbm.xml +++ b/src/com/Xz.hbm.xml @@ -11,13 +11,13 @@ - + - - + + - + diff --git a/src/com/Xz.java b/src/com/Xz.java index be20990..b3a5ab5 100644 --- a/src/com/Xz.java +++ b/src/com/Xz.java @@ -12,14 +12,14 @@ public class Xz extends AbstractXz implements java.io.Serializable { } /** minimal constructor */ - public Xz( String title, Integer sep) { - super(title, sep); + public Xz(Integer id, String title, Integer sep) { + super(id, title, sep); } /** full constructor */ - public Xz(String title, String desc, Integer sep, Integer orp, + public Xz(String title, String miao, Integer sep, Integer orp, String postage, String wx, String tel, String qq) { - super(title, desc, sep, orp, postage, wx, tel, qq); + super(title, miao, sep, orp, postage, wx, tel, qq); } } diff --git a/src/hibernate.cfg.xml b/src/hibernate.cfg.xml index 0bf69d0..bd907a2 100644 --- a/src/hibernate.cfg.xml +++ b/src/hibernate.cfg.xml @@ -24,6 +24,7 @@ true + diff --git a/src/struts.xml b/src/struts.xml index 60d93cd..4e55a43 100644 --- a/src/struts.xml +++ b/src/struts.xml @@ -23,6 +23,10 @@ /welcome.jsp /success.jsp + +/welcome.jsp +/success.jsp + diff --git a/success.jsp b/success.jsp deleted file mode 100644 index b679216..0000000 --- a/success.jsp +++ /dev/null @@ -1,9 +0,0 @@ -<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> -<%@ taglib prefix="s" uri="/struts-tags" %> - -注册成功页面 - -

注册成功

- -

返回首页

- diff --git a/welcome.jsp b/welcome.jsp deleted file mode 100644 index 857d2e9..0000000 --- a/welcome.jsp +++ /dev/null @@ -1,7 +0,0 @@ -<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> - -登陆成功 - -

欢迎登陆本系统

- - \ No newline at end of file