- 浏览: 151225 次
- 性别:
- 来自: 深圳
文章分类
最新评论
-
hx0637:
楼主!小弟要面临面试了,能否指导下小弟?
面试 深圳一家公司的 -
kljismi:
你好,我现在正在开这项目的代码,但是我不明白@Privileg ...
权限管理模块分析 -
yzhw:
终于找到了
ImageSizer.java -
sunloveny:
国
struts国际化 -
jackotty:
谢谢楼主的分享
struts validator验证框架
UserForm.java
IUserDAO.java
IUserDAOImpl.java
/* * Generated by MyEclipse Struts * Template path: templates/java/JavaClass.vtl */ package org.lxh.myzngt.struts.form; import javax.servlet.http.HttpServletRequest; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionMessage; /** * MyEclipse Struts Creation date: 06-30-2007 * * XDoclet definition: * * @struts.form name="userForm" */ public class UserForm extends ActionForm { /* * Generated fields */ /** sex property */ private String sex = "男" ; /** usermail property */ private String usermail; /** userques property */ private String userques; /** userid property */ private String userid; /** realname property */ private String realname; /** userans property */ private String userans; /** userpwd property */ private String userpwd; private String confirmpwd; private String checkcode; /** grade property */ private String grade; /** integral property */ private String integral; /** id property */ private String id; private int type; // 1:表示注册功能 // 2:表示登陆 // 3:表示忘记密码,确认用户是否存在 // 4:表示修改密码 /* * Generated Methods */ /** * Method validate * * @param mapping * @param request * @return ActionErrors */ public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if (type == 1) { if (this.userid == null || "".equals(this.userid)) { errors.add("userid", new ActionMessage("user.userid.null")); } if (this.userpwd == null || "".equals(this.userpwd)) { errors.add("userpwd", new ActionMessage("user.userpwd.null")); } else { if (!(this.userpwd.equals(this.confirmpwd))) { errors.add("configpwd", new ActionMessage( "user.confirmpwd.error")); } } if (this.userques == null || "".equals(this.userques)) { errors.add("userques", new ActionMessage("user.userques.null")); } if (this.userans == null || "".equals(this.userans)) { errors.add("userans", new ActionMessage("user.userans.null")); } if (this.checkcode == null || "".equals(this.checkcode)) { errors.add("checkcode", new ActionMessage("checkcode.null")); } } if (type == 2) { if (this.userid == null || "".equals(this.userid)) { errors.add("userid", new ActionMessage("user.userid.null")); } if (this.userpwd == null || "".equals(this.userpwd)) { errors.add("userpwd", new ActionMessage("user.userpwd.null")); } if (this.checkcode == null || "".equals(this.checkcode)) { errors.add("checkcode", new ActionMessage("checkcode.null")); } } if (type == 3) { if (this.userid == null || "".equals(this.userid)) { errors.add("userid", new ActionMessage("user.userid.null")); } if (this.userques == null || "".equals(this.userques)) { errors.add("userques", new ActionMessage("user.userques.null")); } if (this.userans == null || "".equals(this.userans)) { errors.add("userans", new ActionMessage("user.userans.null")); } if (this.checkcode == null || "".equals(this.checkcode)) { errors.add("checkcode", new ActionMessage("checkcode.null")); } } if (type == 4) { if (this.userid == null || "".equals(this.userid)) { errors.add("userid", new ActionMessage("user.userid.null")); } if (this.userpwd == null || "".equals(this.userpwd)) { errors.add("userpwd", new ActionMessage("user.userpwd.null")); } else { if (!(this.userpwd.equals(this.confirmpwd))) { errors.add("configpwd", new ActionMessage( "user.confirmpwd.error")); } } if (this.checkcode == null || "".equals(this.checkcode)) { errors.add("checkcode", new ActionMessage("checkcode.null")); } } return errors; } /** * Method reset * * @param mapping * @param request */ public void reset(ActionMapping mapping, HttpServletRequest request) { // TODO Auto-generated method stub this.checkcode = "" ; } /** * Returns the sex. * * @return String */ public String getSex() { return sex; } /** * Set the sex. * * @param sex * The sex to set */ public void setSex(String sex) { this.sex = sex; } /** * Returns the usermail. * * @return String */ public String getUsermail() { return usermail; } /** * Set the usermail. * * @param usermail * The usermail to set */ public void setUsermail(String usermail) { this.usermail = usermail; } /** * Returns the userques. * * @return String */ public String getUserques() { return userques; } /** * Set the userques. * * @param userques * The userques to set */ public void setUserques(String userques) { this.userques = userques; } /** * Returns the userid. * * @return String */ public String getUserid() { return userid; } /** * Set the userid. * * @param userid * The userid to set */ public void setUserid(String userid) { this.userid = userid; } /** * Returns the realname. * * @return String */ public String getRealname() { return realname; } /** * Set the realname. * * @param realname * The realname to set */ public void setRealname(String realname) { this.realname = realname; } /** * Returns the userans. * * @return String */ public String getUserans() { return userans; } /** * Set the userans. * * @param userans * The userans to set */ public void setUserans(String userans) { this.userans = userans; } /** * Returns the userpwd. * * @return String */ public String getUserpwd() { return userpwd; } /** * Set the userpwd. * * @param userpwd * The userpwd to set */ public void setUserpwd(String userpwd) { this.userpwd = userpwd; } /** * Returns the grade. * * @return String */ public String getGrade() { return grade; } /** * Set the grade. * * @param grade * The grade to set */ public void setGrade(String grade) { this.grade = grade; } /** * Returns the integral. * * @return String */ public String getIntegral() { return integral; } /** * Set the integral. * * @param integral * The integral to set */ public void setIntegral(String integral) { this.integral = integral; } /** * Returns the id. * * @return String */ public String getId() { return id; } /** * Set the id. * * @param id * The id to set */ public void setId(String id) { this.id = id; } public String getConfirmpwd() { return confirmpwd; } public void setConfirmpwd(String confirmpwd) { this.confirmpwd = confirmpwd; } public int getType() { return type; } public void setType(int type) { this.type = type; } public String getCheckcode() { return checkcode; } public void setCheckcode(String checkcode) { this.checkcode = checkcode; } }
IUserDAO.java
package org.lxh.myzngt.dao; import java.util.List; import org.lxh.myzngt.vo.User; public interface IUserDAO { // 按userid查找用户 public User queryByUserid(String userid) throws Exception; // 用户注册 public void register(User user) throws Exception; // 登陆验证 public boolean login(User user) throws Exception; // 找回密码操作 --> 允许用户修改密码 public void updateUserpwd(String userid, String userpwd) throws Exception; // 根据提示问题、答案、用户名确定此用户是否存在 public boolean isExists(String userid, String userques, String userans) throws Exception; // 增加得分 public void addIntegral(String userid, int itergral) throws Exception; // 更新用户 public void update(User user) throws Exception; // 列出全部用户 public List queryAll(int currentPage, int lineSize) throws Exception; // 求出全部的记录数 public int getAllCount() throws Exception; // 删除用户 public void delete(String userid) throws Exception; // 修改用户积分 public void updateIntegral(String userid, int integral) throws Exception; }
IUserDAOImpl.java
package org.lxh.myzngt.dao.impl; import java.util.List; import org.hibernate.Query; import org.lxh.myzngt.dao.IUserDAO; import org.lxh.myzngt.vo.User; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; public class IUserDAOImpl extends HibernateDaoSupport implements IUserDAO { public void register(User user) throws Exception { super.getSession().save(user); } public User queryByUserid(String userid) throws Exception { User user = null; String hql = "FROM User AS u WHERE u.userid=?"; Query q = super.getSession().createQuery(hql); q.setString(0, userid); List all = q.list(); if (all.size() > 0) { user = (User) all.get(0); } return user; } public boolean isExists(String userid, String userques, String userans) throws Exception { boolean flag = false; String hql = "FROM User AS u WHERE u.userid=? AND u.userques=? AND u.userans=?"; Query q = super.getSession().createQuery(hql); q.setString(0, userid); q.setString(1, userques); q.setString(2, userans); List all = q.list(); if (all.size() > 0) { flag = true; } return flag; } public boolean login(User user) throws Exception { boolean flag = false; String hql = "FROM User AS u WHERE u.userid=? AND u.userpwd=?"; Query q = super.getSession().createQuery(hql); q.setString(0, user.getUserid()); q.setString(1, user.getUserpwd()); List all = q.list(); if (all.size() > 0) { flag = true; User t = (User) all.get(0); user.setGrade(t.getGrade()); } return flag; } public void updateUserpwd(String userid, String userpwd) throws Exception { String hql = "UPDATE User SET userpwd=? WHERE userid=?"; Query q = super.getSession().createQuery(hql); q.setString(0, userpwd); q.setString(1, userid); q.executeUpdate(); } public void addIntegral(String userid, int itergral) throws Exception { String hql = "FROM User AS u WHERE u.userid=?"; Query q = super.getSession().createQuery(hql); q.setString(0, userid); User user = (User) q.list().get(0); user.setIntegral(user.getIntegral() + itergral); user.setGrade(org.lxh.myzngt.util.IntegralGrade.getInstance().getGrade( user.getIntegral())); hql = "UPDATE User SET integral=?,grade=? WHERE userid=?"; q = super.getSession().createQuery(hql); q.setInteger(0, user.getIntegral()); q.setInteger(1, user.getGrade()); q.setString(2, userid); q.executeUpdate(); } public void update(User user) throws Exception { String hql = "UPDATE User SET userpwd=?,userques=?,userans=?,usermail=?,integral=?,grade=?,sex=?,realname=? where userid=?"; Query q = super.getSession().createQuery(hql); q.setString(0, user.getUserpwd()); q.setString(1, user.getUserques()); q.setString(2, user.getUserans()); q.setString(3, user.getUsermail()); q.setInteger(4, user.getIntegral()); q.setInteger(5, user.getGrade()); q.setString(6, user.getSex()); q.setString(7, user.getRealname()); q.setString(8, user.getUserid()); q.executeUpdate(); } public void delete(String userid) throws Exception { String hql = "DELETE FROM User WHERE userid=?"; Query q = super.getSession().createQuery(hql); q.setString(0, userid); q.executeUpdate(); } public List queryAll(int currentPage, int lineSize) throws Exception { List all = null; String hql = "FROM User AS u"; Query q = super.getSession().createQuery(hql); q.setFirstResult((currentPage - 1) * lineSize); q.setMaxResults(lineSize); all = q.list(); return all; } public int getAllCount() throws Exception { int count = 0; String hql = "SELECT COUNT(u.id) FROM User AS u"; Query q = super.getSession().createQuery(hql); count = (Integer) q.list().get(0); return count; } public void updateIntegral(String userid, int integral) throws Exception { String hql = "UPDATE User SET integral=?,grade=? WHERE userid=?"; Query q = super.getSession().createQuery(hql); q.setInteger(0, integral); q.setInteger(1, org.lxh.myzngt.util.IntegralGrade.getInstance() .getGrade(integral)); q.setString(2, userid); q.executeUpdate(); } }
发表评论
-
WebRoot\jsp\ques
2008-12-25 23:16 938question.jsp <%@ page cont ... -
MyZhiNangTuanDemo\src\org\lxh\myzngt\vo
2008-12-25 22:42 1103User.java package org.lxh.myz ... -
MyZhiNangTuanDemo\WebRoot\WEB-INF
2008-12-25 22:06 1032web.xml <?xml version=" ... -
org.lxh.myzngt.util
2008-12-25 21:46 962MD5Code.java package org.lxh.m ... -
ApplicationResources.properties
2008-12-25 21:41 1119# Resources for parameter 'org. ... -
org.lxh.myzngt.filter
2008-12-25 21:26 1021AdminLoginFilter.java packa ... -
\WebRoot\jsp
2008-12-25 20:09 1136index.jsp <%@ page co ... -
WebRoot
2008-12-25 19:43 900temp.htm <html> <he ... -
applicationContext.xml
2008-12-25 19:39 1026<?xml version="1.0" ... -
我的智囊团—数据库创建脚本.sql
2008-12-25 17:50 1600/*============================= ...
相关推荐
Android Superuser源码详解 Android操作系统以其开放性和可定制性深受开发者喜爱,而Superuser则是Android系统中一个至关重要的组件,它为用户提供管理root权限的能力。本文将深入探讨Superuser的源码,揭示其在...
**User-Agent Switcher for Chrome 汉化版**是一款针对谷歌浏览器(Chrome)设计的扩展程序,它允许用户轻松地更改浏览器发送的User-Agent字符串,从而模拟不同设备或浏览器环境来访问网页。这个功能在进行网页开发...
在C#编程中,消息传递是UI组件之间通信的关键机制,特别是当我们在用户控件(UserControl)和主窗体(Form)之间需要交换数据时。本文将深入探讨如何使用委托(Delegate)来实现这一目标,确保代码的灵活性和可维护性。 ...
CMW500_UserManual.pdf,CMW_WLAN_UserManual.pdf,CMW_WiMAX_UserManual.pdf,CMW_WCDMA_UserManual_V2-1-30.pdf,CMW_TD-SCDMA_UserManual.pdf,CMW_LTE_UserManual.pdf,CMW_GSM_UserManual_V2-1-25.pdf,CMW_GPRF_User...
UserControl是WPF中创建自定义控件的一种基础类型,它允许开发者将多个内置控件组合成一个复合控件,以满足特定的需求。本教程将深入讲解如何制作和使用UserControl,特别适合那些对WPF自定义控件不熟悉的初学者。 ...
Allegro是一款广泛应用于PCB设计领域的专业软件,其User Preferences设置是用户个性化定制工作环境、优化设计流程的关键环节。在“allegro_user preferences详解1-2”中,我们将深入探讨这一主题,帮助用户更好地...
在C#编程中,UserControl是一种自定义控件,它允许开发者组合多个基本控件以创建复杂的用户界面组件。在Windows Forms应用程序中,我们经常需要在UserControl与主窗体之间进行数据或事件的交互,这通常涉及到消息...
`db.createUser` 方法就是用于创建具有特定权限的用户的。以下是对 `db.createUser` 使用的详细介绍: ### 1. `db.createUser` 方法的官方文档参考 `db.createUser` 方法允许管理员创建新的用户账户,其基本语法...
Secure User Plane Location (SUPL) is an Enabler which utilizes existing standards where available and possible, to transfer assistance data and positioning data over a User Plane bearer, such as IP, ...
- HSPICE User Guide: Simulation and Analysis, version C-2009.03 - HSPICE User Guide: RF Analysis, version C-2009.03 - HSPICE User Guide: Signal Integrity, version C-2009.03 - HSPICE User Guide: ...
在标题提到的"sid2user&user2sid"中,我们涉及了两个关键工具:sid2user和user2sid,它们是由Evgenii Rudnyi开发的,用于进行SID与用户名之间的转换。 sid2user工具的主要功能是从SID(安全标识符)查找对应的...
* 脚本内容可以是:net localgroup "power users" hust\user5 /add,请将hust替换为您自己的域的NetBIOS名称,user5替换为您登录的域用户。 知识点三:创建组策略和启动脚本 * 需要在域控制器上创建一个名为test的...
在.NET框架中,Windows Forms应用程序经常需要在不同的控件之间传递数据,特别是在主窗体(Form)和用户控件(UserControl)之间。本话题主要探讨如何利用委托和事件来实现在Form中显示UserControl,并确保两者之间...
【VectorCast_user_code】使用教程 VectorCast是一款广泛应用于软件测试,尤其是单元测试(UT)的自动化测试工具。本教程将详细介绍如何利用VectorCast的User Code功能,以提高测试的灵活性和效率。User Code允许...
User-Agent字符串包含了访问网站的客户端信息,如浏览器类型、版本、操作系统等。在Java开发中,有一个名为`User-Agent Utilities`的库,由Harald Walker开发,其版本号可能为2a6db83,这正是我们要讨论的焦点。 这...
用户协同过滤(User-Based Collaborative Filtering,简称UserCF)是一种推荐系统中常用的技术,它基于用户的历史行为数据来预测用户可能对未评价物品的兴趣。在本文中,我们将深入探讨UserCF的工作原理、Python实现...
最 终用户需要安装DirectX End-User Runtime,才能让应用了新技术特征的程序顺利执行。多数新开发的游戏需要该安装包的支持。 DirectX End-User Runtimes (June 2010)包含DX9、DX10、DX11。 安装了DirectX End-User...
pt_user_guide.pdf 文件知识点概述 pt_user_guide.pdf 文件是 Synopsys 公司为 PrimeTime 和 PrimeTime SI 软件发布的用户手册。该手册的主要内容包括了对 PrimeTime 和 PrimeTime SI 软件的介绍、安装、配置、使用...
在批量管理用户账户时,`net user` 的批处理功能显得尤为重要,尤其是在大型网络环境中,可以极大地提高工作效率。 在本文中,我们将详细讨论如何使用`net user` 命令批量修改用户密码,并使其永不过期,这对于系统...
在C# WinForm应用开发中,用户控件(UserControl)是一种自定义控件,它允许开发者组合多个标准控件并作为一个单一的组件使用。在实际项目中,我们经常需要在窗体(Form)和用户控件之间传递数据,以便实现更复杂的...