myeclipse自带json包及json插件使用法

上传人:豆浆 文档编号:11122975 上传时间:2017-10-12 格式:DOC 页数:8 大小:76.50KB
返回 下载 相关 举报
myeclipse自带json包及json插件使用法_第1页
第1页 / 共8页
myeclipse自带json包及json插件使用法_第2页
第2页 / 共8页
myeclipse自带json包及json插件使用法_第3页
第3页 / 共8页
myeclipse自带json包及json插件使用法_第4页
第4页 / 共8页
myeclipse自带json包及json插件使用法_第5页
第5页 / 共8页
点击查看更多>>
资源描述

《myeclipse自带json包及json插件使用法》由会员分享,可在线阅读,更多相关《myeclipse自带json包及json插件使用法(8页珍藏版)》请在金锄头文库上搜索。

1、为什么要用 myeclipse 自带的 json 包及 json 插件呢?一句话,方便,不用找 struts2相匹配的 json 插件,这是优点,缺点是 json 新开发的功能没有。不过 json 原有的功能已经够使用了。1、新建 web project2、添加 struts2框架(add struts2 capabilities)3、选择请求方式,/.*4、查看项目文件夹下 Struts2 Core Libraries 文件夹下是否有 json 的 jar 包及 json 插件5、创建 action、dao、实体类( User) ,json 使用实例action 类 代码-package w

2、oye.action;import java.util.List;import javax.servlet.http.HttpSession;import org.apache.struts2.ServletActionContext;import woye.dao.bean.User;import woye.dao.impl.UserDaoImpl;import woye.exceptions.DaoException;import woye.exceptions.ParameterException;import woye.exceptions.ValidateException;impo

3、rt woye.util.MD5;import com.opensymphony.xwork2.ActionSupport;public class UserAction extends ActionSupport /* */private static final long serialVersionUID = 1L;private UserDaoImpl userDao = new UserDaoImpl();public User user;public User getUser() return user;public void setUser(User user) this.user

4、 = user;/ 登录public String login() throws DaoException, ValidateException, Exception if(user=null | user.equals()return ERROR;if(user.getNickName()=null|user.getNickName().equals()return ERROR;if(user.getPassWord()=null|user.getPassWord().equals()return ERROR;user = userDao.userLogon(user.getNickName

5、(), user.getPassWord();System.out.println(user.toString();if(user != null & !user.equals() return SUCCESS;return ERROR;-dao 类 代码-package woye.dao.impl;import java.util.List;import woye.dao.IUser;import woye.dao.base.BaseDAOImpl;import woye.dao.bean.User;import woye.exceptions.DaoException;import woy

6、e.exceptions.ParameterException;import woye.exceptions.ValidateException;import woye.util.MD5;public class UserDaoImpl extends BaseDAOImpl / 登录public User userLogon(String userName, String userPwd) throws DaoException,ValidateException, Exception StringBuffer strSql = new StringBuffer();strSql.appen

7、d(SELECT USERID AS userId,NICKNAME AS nickName,PASSWORD AS PassWord,TELEPHONE AS telephone,STATUS AS status,logtime as logtime);strSql.append( FROM td_user);strSql.append( where nickName= + userName + );strSql.append( and passWord= + userPwd + );System.out.println(= + strSql);return (User) getObject

8、(strSql, User.class);注:BaseDAOImpl 是一个父类 dao,完成了基本的增删改查的功能,另外此实例的 JDBC 使用了 DBUtils 框架,也就是 BaseDAOImpl 中各个功能都是由 DBUtils 完成的-实体类(user)-package woye.dao.bean;public class User / 用户编号private String userId;/ 昵称private String nickName;/ 密码private String passWord;/ 手机号private String telephone;/ 发布时间private

9、 String logtime;/ 状态private String status;public String getUserId() return userId;public void setUserId(String userId) this.userId = userId;public String getPassWord() return passWord;public void setPassWord(String passWord) this.passWord = passWord;public String getNickName() return nickName;public

10、 void setNickName(String nickName) this.nickName = nickName;public String getTelephone() return telephone;public void setTelephone(String telephone) this.telephone = telephone;public String getLogtime() return logtime;public void setLogtime(String logtime) this.logtime = logtime;public String getSta

11、tus() return status;public void setStatus(String status) this.status = status;Overridepublic String toString() return User logtime= + logtime + , nickName= + nickName+ , passWord= + passWord + , status= + status+ , telephone= + telephone + , userId= + userId + ;public User() super();public User(String passWord, String nickName, String telephone,String logtime, String status) super();this.nickName = nickName;this.passWord = passWord;this.telephone = telephone;this.logtime = logtime;this.status = status;注:user 用的上的属性就三个,id,name,password,其余的不要了,我懒了就没删,自己敲吧,要是复制就没有学习的意义了,这都省了好多。-6、struts.xml-

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 行业资料 > 其它行业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号