UserBiz

public interface UserBiz {
public List<User> list(User user);
public int add(User user);
public List<TreeNode> listNode(); }

UserBizImpl

public class UserBizImpl implements UserBiz {

    private UserDao userDao ;

    public UserDao getUserDao() {
return userDao;
} public void setUserDao(UserDao userDao) {
this.userDao = userDao;
} @Override
public List<User> list(User user) {
return userDao.list(user);
} @Override
public int add(User user) {
// TODO Auto-generated method stub
return userDao.add(user);
} @Override
public List<TreeNode> listNode() {
// TODO Auto-generated method stub
return userDao.listNode();
} }

UserDao

public class UserDao extends BaseDao {

    private static final long serialVersionUID = -1213415622340269960L;

    public List<User> list(User user){

        return this.getHibernateTemplate().execute(new HibernateCallback<List<User>>() {

            @Override
public List<User> doInHibernate(Session arg0) throws HibernateException {
Query query = arg0.createQuery("from User");
String uname = user.getUname();
String upwd = user.getUpwd();
if(StringUtils.isNotBlank(uname)&& StringUtils.isNotBlank(upwd)) {
query = arg0.createQuery("from User where uname = :uname and upwd = :upwd ");
query.setParameter("uname", uname);
query.setParameter("upwd", upwd);
}
return query.list();
}
});
} public int add(User user) {
Serializable a = this.getHibernateTemplate().save(user);
int n = 0;
if(StringUtils.isNotBlank(a+"")) {
n=1;
}
return n;
} public List<TreeNode> listNode(){ return this.getHibernateTemplate().execute(new HibernateCallback<List<TreeNode>>() { @Override
public List<TreeNode> doInHibernate(Session session) throws HibernateException {
return session.createQuery("from TreeNode").list();
}
});
} }

entity

public class User extends BaseEntity {

    private static final long serialVersionUID = 6566515100091330894L;

    private String uname;
private String upwd;
public String getUname() {
return uname;
}
public void setUname(String uname) {
this.uname = uname;
}
public String getUpwd() {
return upwd;
}
public void setUpwd(String upwd) {
this.upwd = upwd;
}
public User(String uname, String upwd) {
super();
this.uname = uname;
this.upwd = upwd;
}
public User() {
super();
}
@Override
public String toString() {
return "User [uname=" + uname + ", upwd=" + upwd + "]";
} }

User.hbm.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class table="t_vue_user" name="com.hmc.user.entity.User">
<id name="uname" type="java.lang.String" column="uname"></id> <property name="upwd" type="java.lang.String" column="pwd"></property>
</class>
</hibernate-mapping>

TreeNode

public class TreeNode extends BaseEntity {

    private static final long serialVersionUID = 3404051699954127467L;

    private int treenodeid;
private String treenodename;
private int treenodetype;
private int parentnodeid;
private String url;
private int position;
private String icon;
public int getTreenodeid() {
return treenodeid;
}
public void setTreenodeid(int treenodeid) {
this.treenodeid = treenodeid;
}
public String getTreenodename() {
return treenodename;
}
public void setTreenodename(String treenodename) {
this.treenodename = treenodename;
}
public int getTreenodetype() {
return treenodetype;
}
public void setTreenodetype(int treenodetype) {
this.treenodetype = treenodetype;
}
public int getParentnodeid() {
return parentnodeid;
}
public void setParentnodeid(int parentnodeid) {
this.parentnodeid = parentnodeid;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public int getPosition() {
return position;
}
public void setPosition(int position) {
this.position = position;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
public TreeNode(int treenodeid, String treenodename, int treenodetype, int parentnodeid, String url, int position,
String icon) {
super();
this.treenodeid = treenodeid;
this.treenodename = treenodename;
this.treenodetype = treenodetype;
this.parentnodeid = parentnodeid;
this.url = url;
this.position = position;
this.icon = icon;
}
public TreeNode() {
super();
}
@Override
public String toString() {
return "TreeNode [treenodeid=" + treenodeid + ", treenodename=" + treenodename + ", treenodetype="
+ treenodetype + ", parentnodeid=" + parentnodeid + ", url=" + url + ", position=" + position
+ ", icon=" + icon + "]";
} }

TreeNode.hbm.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class table="t_vue_tree_node" name="com.hmc.node.entity.TreeNode">
<id name="treenodeid" type="java.lang.Integer" column="tree_node_id">
<generator class="increment"></generator>
</id> <property name="treenodename" type="java.lang.String" column="tree_node_name"></property>
<property name="treenodetype" type="java.lang.Integer" column="tree_node_type"></property>
<property name="parentnodeid" type="java.lang.Integer" column="parent_node_id"></property>
<property name="url" type="java.lang.String" column="url"></property>
<property name="position" type="java.lang.Integer" column="position"></property>
<property name="icon" type="java.lang.String" column="icon"></property>
</class>
</hibernate-mapping>

UserAction

public class UserAction extends BaseAction implements ModelDriven<User> {

    private static final long serialVersionUID = -1655051258255282376L;

    private User user = new User();

    private UserBiz userBiz ;

    public User getUser() {
return user;
} public void setUser(User user) {
this.user = user;
} public String dologin() { List<User> list = userBiz.list(user);
if(list.size()>0) {
System.out.println("登录成功");
}
else {
System.out.println("登录失败,用户名或密码错误");
}
return null;
} public String addUser() { int n = userBiz.add(user);
if(n>0) {
System.out.println("注册成功");
}
else {
System.out.println(“注册失败");
} return null;
} public String list() { List<User> list = userBiz.list(user);
for (User user : list) {
System.out.println(user);
} return null;
} public String listNode() {
List<TreeNode> listNode = userBiz.listNode();
for (TreeNode treeNode : listNode) {
System.out.println(treeNode);
} return null;
} public UserBiz getUserBiz() {
return userBiz;
} public void setUserBiz(UserBiz userBiz) {
this.userBiz = userBiz;
} @Override
public User getModel() {
// TODO Auto-generated method stub
return user;
} }

spring-user.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd"> <bean id="userDao" class="com.hmc.user.dao.UserDao" parent="baseDao" ></bean>
<bean id="userBiz" class="com.hmc.user.biz.Impl.UserBizImpl" parent="baseBiz" >
<property name="userDao" ref="userDao"></property>
</bean> <bean id="userAction" class="com.hmc.user.web.UserAction" parent="baseAction">
<property name="userBiz" ref="userBiz"></property>
</bean> </beans>

struts-user.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
"http://struts.apache.org/dtds/struts-2.5.dtd">
<struts>
<package name="user" extends="base" >
<action name="user_*" class="userAction" method="{1}"> </action>
</package>
</struts>

ArticleBiz

public interface ArticleBiz {

    public interface ArticlesBiz {
public List<Articles> list();
public int add(Articles articles);
public int edit(Articles articles);
public int delete(Articles articles); } }

ArticlesBizImpl

public class ArticlesBizImpl implements ArticlesBiz {

    private ArticlesDao articlesDao ;

    public ArticlesDao getArticlesDao() {
return articlesDao;
} public void setArticlesDao(ArticlesDao articlesDao) {
this.articlesDao = articlesDao;
} @Override
public List<Articles> list() {
// TODO Auto-generated method stub
return articlesDao.list();
} @Override
public int add(Articles articles) {
// TODO Auto-generated method stub
return articlesDao.add(articles);
} @Override
public int edit(Articles articles) {
// TODO Auto-generated method stub
return articlesDao.edit(articles);
} @Override
public int delete(Articles articles) {
// TODO Auto-generated method stub
return articlesDao.delete(articles);
} }

ArticlesDao

public class ArticlesDao extends BaseDao {

    private static final long serialVersionUID = 6720176337331636573L;

    public List<Articles> list(){

        return this.getHibernateTemplate().execute(new HibernateCallback<List<Articles>>() {

            @Override
public List<Articles> doInHibernate(Session session) throws HibernateException { return session.createQuery("from Articles").list();
}
});
} public int add(Articles articles) { Serializable a = this.getHibernateTemplate().save(articles);
int n = 0;
System.out.println("add~"+a);
if(StringUtils.isNotBlank(a+"")) {
n = 1;
}
return n;
} public int edit(Articles articles) { this.getHibernateTemplate().update(articles); return 1;
} public int delete(Articles articles) { this.getHibernateTemplate().delete(articles); return 1;
} }

Articles

public class Articles extends BaseEntity {

        private static final long serialVersionUID = -6188029223617912462L;

        private int id;
private String title;
private String body;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getBody() {
return body;
}
public void setBody(String body) {
this.body = body;
}
public Articles(int id, String title, String body) {
super();
this.id = id;
this.title = title;
this.body = body;
}
public Articles() {
super();
}
@Override
public String toString() {
return "Articles [id=" + id + ", title=" + title + ", body=" + body + "]";
} }

Articles.hbm.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class table="t_vue_articles" name="com.hmc.articles.entity.Articles">
<id name="id" type="java.lang.Integer" column="id">
<generator class="increment"></generator>
</id> <property name="title" type="java.lang.String" column="title"></property>
<property name="body" type="java.lang.String" column="body"></property>
</class>
</hibernate-mapping>

ArticlesAction

public class ArticlesAction extends BaseAction implements ModelDriven<Articles> {

    private static final long serialVersionUID = 5944659149847110488L;

    private Articles articles = new Articles();

    private ArticlesBiz articlesBiz ;

    public ArticlesBiz getArticlesBiz() {
return articlesBiz;
} public void setArticlesBiz(ArticlesBiz articlesBiz) {
this.articlesBiz = articlesBiz;
} public String list() {
List<Articles> list = articlesBiz.list();
for (Articles a : list) {
System.out.println(a);
} return null;
} public String add() {
articlesBiz.add(articles); return null;
}
public String edit() {
articlesBiz.edit(articles); return null;
}
public String del() {
articlesBiz.delete(articles); return null;
} @Override
public Articles getModel() {
// TODO Auto-generated method stub
return articles;
} }

spring-articles.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd"> <bean id="articlesDao" class="com.hmc.article.dao.ArticlesDao" parent="baseDao" ></bean>
<bean id="articlesBiz" class="com.hmc.article.biz.ArticlesBizImpl" parent="baseBiz" >
<property name="articlesDao" ref="articlesDao"></property>
</bean> <bean id="articlesAction" class="com.hmc.article.web.ArticlesAction" parent="baseAction" scope="proptype">
<property name="articlesBiz" ref="articlesBiz"></property>
</bean> </beans>

struts-articles.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
"http://struts.apache.org/dtds/struts-2.5.dtd">
<struts>
<package name="articles" extends="base" namespace="/articles">
<action name="/articles_*" class="articlesAction" method="{1}"> </action>
</package>
</struts>

结果

ssh2的更多相关文章

  1. JAVAWEB贵美网上商城完整项目源码(SSH2)

    JAVAWEB贵美网上商城完整项目源码(SSH2) 贵美网上商城原是北大青鸟的一个内部项目,项目采用 struts2+spring4+hibernate4+MySQL等技术实现,数据库连接池采用c3p ...

  2. 解决:Could not parse response code.Server Reply: SSH-2.0-OpenSSH_5.3

    [摘要:办理:org.apache.commons.net.MalformedServerReplyException: Could not parse response code.Server Re ...

  3. JBPM4.4与SSH2之整合

    JBPM4.4与SSH2之整合(附完整源码) 这是我来到这世上二十多年来,第二次写博客啊.哈哈  这些天,想着把jbpm4.4与ssh2整合一下,由于之前从来没用过jbpm,也不知道各版本之间会有什么 ...

  4. ssh2 php扩展

    如何通过PHP启动和关闭远程服务器上的某个软件,譬如Memcached.对于俺这个刚刚掌握PHP编程皮毛的菜鸟来说,最直接不过的想法就是用exec函数执行SSH命令呗,先把运行Apache+PHP的服 ...

  5. php的ssh2扩展安装

    折腾半天,结论如下: 1.先需要openssl 用which openssl看是否已安装 2.然后libssh2 用rpm -ql libssh2查看 3.下载源码的shh2x.x.x.tgz的包 4 ...

  6. ssh2框架搭建

    原文:ssh2框架搭建 struts2+spring4.0+hibernate4.0 4.x版本与3.x版本有较大区别,要配置方法须要注意,用到的jar包如下 文件结构 src/application ...

  7. nodejs ssh2

    https://www.npmjs.com/package/ssh2 npm install ssh2  ssh2文件下载: //前台命令下发 app.get('/test/fileDownload' ...

  8. linux 用 SSH2协议远程连接并控制 linux

    [参考链接](http://php.net/manual/zh/ssh2.installation.php) ssh2_exec 并不能打印所有的命令的提示信息 如果有返回的字符串信息,可以打印,或重 ...

  9. putty实现自动登录的方法(ssh和ssh2)

    介绍putty实现自动登录的方法.   1.登录主机并输入ssh-keygen -t rsa  提示Enter file in which to save the key (/root/.ssh/id ...

  10. Ganymed SSH-2 for Java

    Ganymed SSH-2 for Java是一个纯Java实现的SHH2库,官网为http://www.ganymed.ethz.ch/ssh2/,最新的更新时间为2006年10月,在用之前,请仔细 ...

随机推荐

  1. PHP 使用 pdo 操作oracle数据库 报错

    ## SELECT UNID,NAME,NAME_XML WHERE UNID>=10 AND UNID<=15 ## 在10到15这5条数据中不为空数据php: symbol looku ...

  2. 矩阵优化DP类问题应用向小结

    前言 本篇强调应用,矩阵的基本知识有所省略(也许会写篇基础向...). 思想及原理 为什么Oier们能够想到用矩阵来加速DP呢?做了一些DP题之后,我们会发现,有时候DP两两状态之间的转移是定向的,也 ...

  3. 【Maven基础入门】02 了解POM文件构建

    温故 上一节我们说过:Maven 是一个基于POM文件的构建工具,当然离不开POM文件 POM文件是一个XML标记语言表示的文件,文件就是:pom.xml 一个POM文件包含了项目的基本信息,用于描述 ...

  4. oracle 分页sql

    select * from ( SELECT A.*, ROWNUM RN FROM ( SELECT A.*,B.USERPWiD from 测试表2 A left join 测试表3 B on A ...

  5. IIS err_connection_timed_out(响应时间过长)

    场景:我在服务器的IIS上部署了一个网站,服务器上可以正常打开,然后我用自己的电脑访问,出现如下错误: 原因:服务器的防火墙对入站规则进行了一些限制. 解决方法:1.打开服务器的防火墙-----> ...

  6. python ocr中文识别库 tesseract安装及问题处理

    这个破东西,折腾了快1个小时,网上的教材太乱了. 我解决的主要是windows的问题 先下载exe.(一看到这个,我就有种预感,不妙) https://digi.bib.uni-mannheim.de ...

  7. JavaWeb 之 Listener:监听器

    一.概述 1.事件监听机制 事件:        一件事情 事件源:    事件发生的地方 监听器:    一个对象 注册监听: 将事件.事件源.监听器绑定在一起. 2.监听器概念 当事件源上发生某个 ...

  8. JavaScript变量存储浅析(一)

    Hello! 上一篇关于JS中函数传参(http://www.cnblogs.com/souvenir/p/4969092.html)的介绍中提到了JS的另外一个基本概念:JS变量存储, 今天我们就用 ...

  9. 用java语言将数据库中的数据表转换为xml文件的通用程序(细化)

    转自:https://www.cnblogs.com/wudage/p/7650685.html 总是在网络上copy别人的源代码,今天我也贴出自己今天写的源码,相信这个程序会对大家在平时的工作中需要 ...

  10. Alpha_4

    一. 站立式会议照片 二. 工作进展 (1) 昨天已完成的工作 a. 我的·主界面设计 b. 番茄钟的页面及音乐选择弹窗页面设计 c. 实现自定义习惯和设置新习惯的功能页面,并可预览 d.已实现番茄钟 ...