commit 522fd0980c184fc258033cc7611718c0772ea0fb Author: dida <480918301@qq.com> Date: Sat Jan 4 09:06:04 2020 +0800 submit diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..720fdb1 --- /dev/null +++ b/.classpath @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..b809f03 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.myhibernatedata b/.myhibernatedata new file mode 100644 index 0000000..43b3612 --- /dev/null +++ b/.myhibernatedata @@ -0,0 +1,24 @@ +#MyEclipse Hibernate Properties +#Fri Jan 03 19:00:56 CST 2020 +sessionFactoryName= +genBasicCompId=true +profile= +daoSFId= +version=3.3 +jndiPath= +detectM2M=false +reStrategyClass= +detectO2O=false +springDaoFile= +useJavaTypes=true +keyGenerator=native +libInstallFolder=WebRoot/WEB-INF/lib +addLibs2Project=true +genVersionTag=false +sessionFactoryId= +basePersistenceClass= +genAnnotations=false +reSettingsFile= +configFile=/Lesson12/src/hibernate.cfg.xml +createConfigFile=true +addLibs2Classpath=true diff --git a/.mymetadata b/.mymetadata new file mode 100644 index 0000000..b007a07 --- /dev/null +++ b/.mymetadata @@ -0,0 +1,13 @@ + + + + + + + diff --git a/.mystrutsdata b/.mystrutsdata new file mode 100644 index 0000000..8589c90 --- /dev/null +++ b/.mystrutsdata @@ -0,0 +1,7 @@ + + + 4 + + 0 + action + diff --git a/.project b/.project new file mode 100644 index 0000000..9c36d38 --- /dev/null +++ b/.project @@ -0,0 +1,65 @@ + + + Lesson12 + + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.jsdt.core.javascriptValidator + + + + + com.genuitec.eclipse.j2eedt.core.WebClasspathBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.genuitec.eclipse.j2eedt.core.J2EEProjectValidator + + + + + com.genuitec.eclipse.j2eedt.core.DeploymentDescriptorValidator + + + + + org.eclipse.wst.validation.validationbuilder + + + + + com.genuitec.eclipse.hibernate.HibernateBuilder + + + + + com.genuitec.eclipse.ast.deploy.core.DeploymentBuilder + + + + + + com.genuitec.eclipse.ast.deploy.core.deploymentnature + com.genuitec.eclipse.hibernate.hibernatenature + org.eclipse.jem.workbench.JavaEMFNature + com.genuitec.eclipse.j2eedt.core.webnature + org.eclipse.jdt.core.javanature + org.eclipse.wst.jsdt.core.jsNature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.common.modulecore.ModuleCoreNature + com.genuitec.eclipse.cross.easystruts.eclipse.easystrutsnature + + diff --git a/.settings/.jsdtscope b/.settings/.jsdtscope new file mode 100644 index 0000000..252e54f --- /dev/null +++ b/.settings/.jsdtscope @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..12f0c82 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Wed Jun 05 10:15:29 CST 2019 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component new file mode 100644 index 0000000..fe47deb --- /dev/null +++ b/.settings/org.eclipse.wst.common.component @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 0000000..9f1491f --- /dev/null +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/.settings/org.eclipse.wst.jsdt.ui.superType.container b/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 0000000..3bd5d0a --- /dev/null +++ b/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/.settings/org.eclipse.wst.jsdt.ui.superType.name b/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 0000000..05bd71b --- /dev/null +++ b/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/WebRoot/1.jsp b/WebRoot/1.jsp new file mode 100644 index 0000000..802a43b --- /dev/null +++ b/WebRoot/1.jsp @@ -0,0 +1,249 @@ +<%@ 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/2.jsp b/WebRoot/2.jsp new file mode 100644 index 0000000..1551b4b --- /dev/null +++ b/WebRoot/2.jsp @@ -0,0 +1,570 @@ +<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> +<% +String path = request.getContextPath(); +String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + MyDay-我的美好一天 + + + + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + +
+ 登录 +
+
    +
  • 美好的一天从MyDay开始
  • +
  • 校园超市为你方便购物
  • +
  • 失物招领让你的宝贝回家
  • +
  • 资源共享丰富你的知识
  • +
  • 跳蚤市场轻松解决你不需要的物品
  • +
+
prev
+
next
+
+
+ + + + + + + + + + + + + + + + + + + + + +
+
+ +
    +
  • +
    +

    OSSEAN

    +

    资源共享平台

    +

    高效汇聚全球开源开放的软件工程大数据,持续分析与评估开源生态发展态势

    +
    +
  • +
  • +
    +

    OSSEAN

    +

    资源共享平台

    +

    高效汇聚全球开源开放的软件工程大数据,持续分析与评估开源生态发展态势

    +
    +
  • +
  • +
    +

    OSSEAN

    +

    资源共享平台

    +

    高效汇聚全球开源开放的软件工程大数据,持续分析与评估开源生态发展态势

    +
    +
  • +
  • +
    +

    OSSEAN

    +

    资源共享平台

    +

    高效汇聚全球开源开放的软件工程大数据,持续分析与评估开源生态发展态势

    +
    +
  • + +
  • +
    +

    OSSEAN

    +

    资源共享平台

    +

    高效汇聚全球开源开放的软件工程大数据,持续分析与评估开源生态发展态势

    +
    +
  • +
+ +
+
+ + + + + + + +
+ + + + + + diff --git a/WebRoot/3.jsp b/WebRoot/3.jsp new file mode 100644 index 0000000..e66f7d8 --- /dev/null +++ b/WebRoot/3.jsp @@ -0,0 +1,317 @@ +<%@ 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+"/"; +%> + + + + + + + 登录|注册 + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ + + + + + 注册 +
+ + +
+
+
+ + + + + 12 + + + + + + +
+

注册

+

忘记密码

+
+ +
+

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

+ +
+
+
+ + + diff --git a/WebRoot/4.jsp b/WebRoot/4.jsp new file mode 100644 index 0000000..455b5a6 --- /dev/null +++ b/WebRoot/4.jsp @@ -0,0 +1,250 @@ +<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> +<% +String path = request.getContextPath(); +String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + My JSP 'PubLost.jsp' starting page + + + + + + + + + + + + + + + + +
+
+
+ + + +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + +
+
+
+ + + + +
+
+ + + + + + + +
+
+ +
+
+
+
+
+
+
+ + + diff --git a/WebRoot/404.jsp b/WebRoot/404.jsp new file mode 100644 index 0000000..106030d --- /dev/null +++ b/WebRoot/404.jsp @@ -0,0 +1,799 @@ + + + +
+ + \ No newline at end of file diff --git a/WebRoot/LostAndFound.jsp b/WebRoot/LostAndFound.jsp new file mode 100644 index 0000000..94b63a0 --- /dev/null +++ b/WebRoot/LostAndFound.jsp @@ -0,0 +1,28 @@ +<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%> +<% +String path = request.getContextPath(); +String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + My JSP 'LostAndFound.jsp' starting page + + + + + + + + + + + + This is my JSP page.
+ + diff --git a/WebRoot/META-INF/MANIFEST.MF b/WebRoot/META-INF/MANIFEST.MF new file mode 100644 index 0000000..254272e --- /dev/null +++ b/WebRoot/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/WebRoot/WEB-INF/classes/RegisterAction.class b/WebRoot/WEB-INF/classes/RegisterAction.class new file mode 100644 index 0000000..0046c6c Binary files /dev/null and b/WebRoot/WEB-INF/classes/RegisterAction.class differ diff --git a/WebRoot/WEB-INF/classes/SubmitXzAction.class b/WebRoot/WEB-INF/classes/SubmitXzAction.class new file mode 100644 index 0000000..fa26cf0 Binary files /dev/null and b/WebRoot/WEB-INF/classes/SubmitXzAction.class differ diff --git a/WebRoot/WEB-INF/classes/com/AbstractUserinfo.class b/WebRoot/WEB-INF/classes/com/AbstractUserinfo.class new file mode 100644 index 0000000..384a86b Binary files /dev/null and b/WebRoot/WEB-INF/classes/com/AbstractUserinfo.class differ diff --git a/WebRoot/WEB-INF/classes/com/AbstractXz.class b/WebRoot/WEB-INF/classes/com/AbstractXz.class new file mode 100644 index 0000000..62ec338 Binary files /dev/null and b/WebRoot/WEB-INF/classes/com/AbstractXz.class differ diff --git a/WebRoot/WEB-INF/classes/com/HibernateSessionFactory.class b/WebRoot/WEB-INF/classes/com/HibernateSessionFactory.class new file mode 100644 index 0000000..8cb583a Binary files /dev/null and b/WebRoot/WEB-INF/classes/com/HibernateSessionFactory.class differ diff --git a/WebRoot/WEB-INF/classes/com/Userinfo.class b/WebRoot/WEB-INF/classes/com/Userinfo.class new file mode 100644 index 0000000..ed47c6a Binary files /dev/null and b/WebRoot/WEB-INF/classes/com/Userinfo.class differ diff --git a/WebRoot/WEB-INF/classes/com/Userinfo.hbm.xml b/WebRoot/WEB-INF/classes/com/Userinfo.hbm.xml new file mode 100644 index 0000000..d293198 --- /dev/null +++ b/WebRoot/WEB-INF/classes/com/Userinfo.hbm.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WebRoot/WEB-INF/classes/com/Xz.class b/WebRoot/WEB-INF/classes/com/Xz.class new file mode 100644 index 0000000..011bb29 Binary files /dev/null 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 new file mode 100644 index 0000000..e62e863 --- /dev/null +++ b/WebRoot/WEB-INF/classes/com/Xz.hbm.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WebRoot/WEB-INF/classes/hibernate.cfg.xml b/WebRoot/WEB-INF/classes/hibernate.cfg.xml new file mode 100644 index 0000000..0bf69d0 --- /dev/null +++ b/WebRoot/WEB-INF/classes/hibernate.cfg.xml @@ -0,0 +1,30 @@ + + + + + + + + + org.hibernate.dialect.MySQLDialect + + + jdbc:mysql://localhost:3306/postgres + + root + 3141592653 + + com.mysql.jdbc.Driver + + + postgres + + true + + + + + + \ No newline at end of file diff --git a/WebRoot/WEB-INF/classes/struts.xml b/WebRoot/WEB-INF/classes/struts.xml new file mode 100644 index 0000000..60d93cd --- /dev/null +++ b/WebRoot/WEB-INF/classes/struts.xml @@ -0,0 +1,29 @@ + + + + + + + +/register.jsp + + +/login.jsp + + +/success.jsp +/error.jsp + + + +/welcome.jsp +/success.jsp + + +/welcome.jsp +/success.jsp + + + + + diff --git a/WebRoot/WEB-INF/lib/mysql-connector-java-5.1.47-bin.jar b/WebRoot/WEB-INF/lib/mysql-connector-java-5.1.47-bin.jar new file mode 100644 index 0000000..fb25d64 Binary files /dev/null and b/WebRoot/WEB-INF/lib/mysql-connector-java-5.1.47-bin.jar differ diff --git a/WebRoot/WEB-INF/web.xml b/WebRoot/WEB-INF/web.xml new file mode 100644 index 0000000..001cb6a --- /dev/null +++ b/WebRoot/WEB-INF/web.xml @@ -0,0 +1,20 @@ + + + + + index.jsp + + + struts2 + + org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter + + + + struts2 + /* + diff --git a/WebRoot/fbqg.jsp b/WebRoot/fbqg.jsp new file mode 100644 index 0000000..07a63ae --- /dev/null +++ b/WebRoot/fbqg.jsp @@ -0,0 +1,231 @@ +<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> +<% +String path = request.getContextPath(); +String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + My JSP 'PubLost.jsp' starting page + + + + + + + + + + + + + + + + +
+
+
+ + + +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + +
+
+ +
+
+ +
+
+ +
+
+ + +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + +
+
+
+ + + + +
+
+ + + + + + + +
+
+ +
+
+
+
+
+
+
+ + + diff --git a/WebRoot/fbxz.jsp b/WebRoot/fbxz.jsp new file mode 100644 index 0000000..87aa6f7 --- /dev/null +++ b/WebRoot/fbxz.jsp @@ -0,0 +1,256 @@ +<%@ 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+"/"; +%> + + + + + + + My JSP 'PubLost.jsp' starting page + + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + +
+
+ +
+
+
+
+
+
+
+ + + diff --git a/WebRoot/img/404.png b/WebRoot/img/404.png new file mode 100644 index 0000000..d1540f7 Binary files /dev/null and b/WebRoot/img/404.png differ diff --git a/WebRoot/img/b21ab51e83991b465e600e0f459c6906.jpg b/WebRoot/img/b21ab51e83991b465e600e0f459c6906.jpg new file mode 100644 index 0000000..f093ffe Binary files /dev/null and b/WebRoot/img/b21ab51e83991b465e600e0f459c6906.jpg differ diff --git a/WebRoot/img/home.png b/WebRoot/img/home.png new file mode 100644 index 0000000..1ee21fd Binary files /dev/null and b/WebRoot/img/home.png differ diff --git a/WebRoot/img/hover.jpg b/WebRoot/img/hover.jpg new file mode 100644 index 0000000..44d5bbd Binary files /dev/null and b/WebRoot/img/hover.jpg differ diff --git a/WebRoot/img/login.png b/WebRoot/img/login.png new file mode 100644 index 0000000..4919361 Binary files /dev/null and b/WebRoot/img/login.png differ diff --git a/WebRoot/img/login1.png b/WebRoot/img/login1.png new file mode 100644 index 0000000..864c92b Binary files /dev/null and b/WebRoot/img/login1.png differ diff --git a/WebRoot/img/login2.png b/WebRoot/img/login2.png new file mode 100644 index 0000000..96347f1 Binary files /dev/null and b/WebRoot/img/login2.png differ diff --git a/WebRoot/img/one.png b/WebRoot/img/one.png new file mode 100644 index 0000000..ea40a38 Binary files /dev/null and b/WebRoot/img/one.png differ diff --git a/WebRoot/img/sLogo.png b/WebRoot/img/sLogo.png new file mode 100644 index 0000000..c22b33a Binary files /dev/null and b/WebRoot/img/sLogo.png differ diff --git a/WebRoot/img/timg.jfif b/WebRoot/img/timg.jfif new file mode 100644 index 0000000..1add403 Binary files /dev/null and b/WebRoot/img/timg.jfif differ diff --git a/WebRoot/index.jsp b/WebRoot/index.jsp new file mode 100644 index 0000000..01d6e3e --- /dev/null +++ b/WebRoot/index.jsp @@ -0,0 +1,18 @@ +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> +<%@ taglib prefix="s" uri="/struts-tags" %> + + + +Hello World + + +

Hello World From Struts2

+
+
+ + +
+ + \ No newline at end of file diff --git a/WebRoot/login.jsp b/WebRoot/login.jsp new file mode 100644 index 0000000..f3fbe9c --- /dev/null +++ b/WebRoot/login.jsp @@ -0,0 +1,16 @@ +<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> +<%@ taglib prefix="s" uri="/struts-tags" %> + +登录页面 + +

请输入用户名和密码

+ + + + + + + + diff --git a/WebRoot/market.jsp b/WebRoot/market.jsp new file mode 100644 index 0000000..8d72301 --- /dev/null +++ b/WebRoot/market.jsp @@ -0,0 +1,28 @@ +<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%> +<% +String path = request.getContextPath(); +String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + My JSP 'market.jsp' starting page + + + + + + + + + + + + This is my JSP page.
+ + diff --git a/WebRoot/register.jsp b/WebRoot/register.jsp new file mode 100644 index 0000000..4d143ee --- /dev/null +++ b/WebRoot/register.jsp @@ -0,0 +1,18 @@ +<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> +<%@ taglib prefix="s" uri="/struts-tags" %> + +用户注册 + +

注册一个新用户

+ + + + + + + + + + + + diff --git a/WebRoot/success.jsp b/WebRoot/success.jsp new file mode 100644 index 0000000..b679216 --- /dev/null +++ b/WebRoot/success.jsp @@ -0,0 +1,9 @@ +<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> +<%@ taglib prefix="s" uri="/struts-tags" %> + +注册成功页面 + +

注册成功

+ +

返回首页

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

欢迎登陆本系统

+ + \ No newline at end of file diff --git a/src/RegisterAction.java b/src/RegisterAction.java new file mode 100644 index 0000000..52e7313 --- /dev/null +++ b/src/RegisterAction.java @@ -0,0 +1,70 @@ +import java.util.List; + + +import javax.persistence.Entity; +import javax.persistence.ManyToOne; +import org.hibernate.Transaction; + +import org.hibernate.Query; +import org.hibernate.Session; +import com.HibernateSessionFactory; +import com.Userinfo; +import com.opensymphony.xwork2.ActionSupport; + + +@Entity +public class RegisterAction extends ActionSupport { + @ManyToOne + private Userinfo user; + + public Userinfo getUser() { + return user; + } + + public void setUser(Userinfo user) { + this.user = user; + } + + @Override + public String execute() throws Exception { + // TODO Auto-generated method stub + return SUCCESS; + } + public String register() throws Exception{ + try{ + Session session=HibernateSessionFactory.getSession(); + Transaction tx=session.beginTransaction(); + session.save(user); + tx.commit(); + return SUCCESS; + }catch(Exception e){ + e.printStackTrace(); + HibernateSessionFactory.getSession().close(); + return ERROR; + } + } + public String login() throws Exception{ + try{ + Session session=HibernateSessionFactory.getSession(); + Transaction tx=session.beginTransaction(); + // Query query=session.createQuery("from Userinfo where username=:uname"); + Query query = session.createQuery("from Userinfo where username=:uname and password=:upassword"); + query.setParameter("uname", user.getUsername()); + query.setParameter("upassword", user.getPassword()); + List list=query.list(); + + tx.commit(); + + if(list.size()>0){ + return SUCCESS; + }else + return ERROR; + }catch(Exception e){ + e.printStackTrace(); + HibernateSessionFactory.getSession().close(); + return ERROR; + } + } + + +} diff --git a/src/SubmitXzAction.java b/src/SubmitXzAction.java new file mode 100644 index 0000000..283fc3f --- /dev/null +++ b/src/SubmitXzAction.java @@ -0,0 +1,40 @@ +import org.hibernate.Session; +import org.hibernate.Transaction; +import com.Xz; +import com.HibernateSessionFactory; +import com.opensymphony.xwork2.ActionSupport; + + +public class SubmitXzAction extends ActionSupport { + + private Xz xz; + + public Xz getXz() { + return xz; + } + + public void setXz(Xz xz) { + this.xz = xz; + } + + @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(xz); + tx.commit(); + return SUCCESS; + }catch(Exception e){ + e.printStackTrace(); + HibernateSessionFactory.getSession().close(); + return ERROR; + } + } + +} diff --git a/src/com/AbstractUserinfo.java b/src/com/AbstractUserinfo.java new file mode 100644 index 0000000..305fc23 --- /dev/null +++ b/src/com/AbstractUserinfo.java @@ -0,0 +1,92 @@ +package com; + +/** + * AbstractUserinfo entity provides the base persistence definition of the + * Userinfo entity. @author MyEclipse Persistence Tools + */ + +public abstract class AbstractUserinfo implements java.io.Serializable { + + // Fields + + private Integer id; + private String username; + private String password; + private Integer age; + private String email; + + // Constructors + + /** default constructor */ + public AbstractUserinfo() { + } + + /** minimal constructor */ + public AbstractUserinfo(Integer id, String password) { + this.id = id; + this.password = password; + } + + /** full constructor */ + /*public AbstractUserinfo(Integer id, String username, String password, + Integer age, String email) { + this.id = id; + this.username = username; + this.password = password; + this.age = age; + this.email = email; + }*/ + public AbstractUserinfo( String username, String password, + Integer age, String email) { + //this.id = id; + this.username = username; + this.password = password; + this.age = age; + this.email = email; + } + // Property accessors + + public Integer getId() { + return this.id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getUsername() { + System.out.println(this.username); + return this.username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + System.out.println(this.password); + return this.password; + + } + + public void setPassword(String password) { + this.password = password; + } + + public Integer getAge() { + return this.age; + } + + public void setAge(Integer age) { + this.age = age; + } + + public String getEmail() { + return this.email; + } + + public void setEmail(String email) { + this.email = email; + } + +} \ No newline at end of file diff --git a/src/com/AbstractXz.java b/src/com/AbstractXz.java new file mode 100644 index 0000000..72613c1 --- /dev/null +++ b/src/com/AbstractXz.java @@ -0,0 +1,123 @@ +package com; + +/** + * AbstractXz entity provides the base persistence definition of the Xz entity. @author + * MyEclipse Persistence Tools + */ + +public abstract class AbstractXz implements java.io.Serializable { + + // Fields + +// private Integer id; + private String title; + private String desc; + private Integer sep; + private Integer orp; + private String postage; + private String wx; + private String tel; + private String qq; + + // Constructors + + /** default constructor */ + public AbstractXz() { + } + + /** minimal constructor */ + public AbstractXz(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) { + this.title = title; + this.desc = desc; + this.sep = sep; + this.orp = orp; + this.postage = postage; + 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 getDesc() { + return this.desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public Integer getSep() { + return this.sep; + } + + public void setSep(Integer sep) { + this.sep = sep; + } + + public Integer getOrp() { + return this.orp; + } + + public void setOrp(Integer orp) { + this.orp = orp; + } + + public String getPostage() { + return this.postage; + } + + public void setPostage(String postage) { + this.postage = postage; + } + + 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/HibernateSessionFactory.java b/src/com/HibernateSessionFactory.java new file mode 100644 index 0000000..5a76433 --- /dev/null +++ b/src/com/HibernateSessionFactory.java @@ -0,0 +1,120 @@ +package com; + +import javax.persistence.Entity; +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 }. + */ +@Entity +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/src/com/Userinfo.hbm.xml b/src/com/Userinfo.hbm.xml new file mode 100644 index 0000000..d293198 --- /dev/null +++ b/src/com/Userinfo.hbm.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/com/Userinfo.java b/src/com/Userinfo.java new file mode 100644 index 0000000..404e390 --- /dev/null +++ b/src/com/Userinfo.java @@ -0,0 +1,33 @@ +package com; + +import javax.persistence.Entity; + +/** + * Userinfo entity. @author MyEclipse Persistence Tools + */ +@Entity +public class Userinfo extends AbstractUserinfo implements java.io.Serializable { + + // Constructors + + /** default constructor */ + public Userinfo() { + } + + /** minimal constructor */ + public Userinfo(Integer id, String password) { + super(id, password); + } + + /** full constructor */ +/* public Userinfo(Integer id, String username, String password, Integer age, + String email) { + super(id, username, password, age, email); + }*/ + public Userinfo( String username, String password, Integer age, + String email) { + super(username, password, age, email); + } + + +} diff --git a/src/com/Xz.hbm.xml b/src/com/Xz.hbm.xml new file mode 100644 index 0000000..e62e863 --- /dev/null +++ b/src/com/Xz.hbm.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/com/Xz.java b/src/com/Xz.java new file mode 100644 index 0000000..be20990 --- /dev/null +++ b/src/com/Xz.java @@ -0,0 +1,25 @@ +package com; + +/** + * Xz entity. @author MyEclipse Persistence Tools + */ +public class Xz extends AbstractXz implements java.io.Serializable { + + // Constructors + + /** default constructor */ + public Xz() { + } + + /** minimal constructor */ + public Xz( String title, Integer sep) { + super(title, sep); + } + + /** full constructor */ + public Xz(String title, String desc, Integer sep, Integer orp, + String postage, String wx, String tel, String qq) { + super(title, desc, sep, orp, postage, wx, tel, qq); + } + +} diff --git a/src/hibernate.cfg.xml b/src/hibernate.cfg.xml new file mode 100644 index 0000000..0bf69d0 --- /dev/null +++ b/src/hibernate.cfg.xml @@ -0,0 +1,30 @@ + + + + + + + + + org.hibernate.dialect.MySQLDialect + + + jdbc:mysql://localhost:3306/postgres + + root + 3141592653 + + com.mysql.jdbc.Driver + + + postgres + + true + + + + + + \ No newline at end of file diff --git a/src/struts.xml b/src/struts.xml new file mode 100644 index 0000000..60d93cd --- /dev/null +++ b/src/struts.xml @@ -0,0 +1,29 @@ + + + + + + + +/register.jsp + + +/login.jsp + + +/success.jsp +/error.jsp + + + +/welcome.jsp +/success.jsp + + +/welcome.jsp +/success.jsp + + + + +