标签:.net 设置 err get code constant password array ring
近期写了一个用户注冊系统,大部分已经写完,可是另一些边角料没写,可是也都是大同小异,我就不再写了,赶着去学习hibernate了,spring还没接触呢!。!
时间好紧迫啊!。!
jsp界面
users的jsp界面
admin的jsp界面
struts.xml配置文件
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd"> <struts> <!--<constant name="struts.i18n.encoding" value="GBK" /> 指定字符编码 --> <!-- 分——————————————————————————————————————割——————————————————————————————————————线 --> <package name="users" extends="struts-default" ><!-- 不收权限控制的Action配置 --> <action name="register" class="com.huizhi.users.action.RegisterAction" method="register"> <!-- 用户注冊Action --> <result name="success">/regsucc.jsp</result> <result name="input">/register.jsp</result> </action> <!-- ****************************************--> <action name="login" class="com.huizhi.users.action.LoginAction" method="login"> <!-- 用户注冊Action --> <result name="success">/main.jsp</result> <result name="input">/index.jsp</result> </action> <!-- ****************************************--> <action name="adminLogin" class="com.huizhi.admin.action.AdminLoginAction" method="adminLogin" > <result name="success">/admin/main.jsp</result> <result name="input">/admin/input.jsp</result> </action> </package> <!-- 分——————————————————————————————————————割——————————————————————————————————————线 --> <package name="users-authority" extends="struts-default"><!-- 收权限控制的Action配置 --> <!-- 定义拦截器 --> <interceptors> <interceptor name="authority" class="com.huizhi.util.AuthorityInterceptor" /> <interceptor-stack name="mydefault"> <interceptor-ref name="defaultStack" /> <interceptor-ref name="authority"></interceptor-ref> </interceptor-stack> </interceptors> <!-- 定义默认拦截器 --> <default-interceptor-ref name="mydefault" /> <!-- 定义全局result --> <global-results> <result name="error">/error.jsp</result> <result name="login" type="redirect">index.jsp</result> </global-results> <!-- ****************************************--> <!-- 查看全部用户 --> <action name="findalluser" class="com.huizhi.users.action.FindAllUsersAction" method="findAllUsers"> <result name="input">/admin/allusers.jsp</result> <result name="success">/allusers.jsp</result> </action> <!-- ****************************************--> <!-- 查看用户个人的信息 --> <action name="selectinfo" class="com.huizhi.users.action.SelectInfoAction" method="selectInfo"> <result name="input"></result> <result name="success">/selectinfo.jsp</result> <result name="find"></result> </action> <!-- ****************************************--> <!-- 改动用户个人的信息 --> <action name="update" class="com.huizhi.users.action.UpdateAction" method="update"> <result name="success">/updatesucc.jsp</result> <result name="input">/selectinfo.jsp</result> </action> <!-- ****************************************--> <!-- 查看全部管理员信息 --> <action name="findalladmin" class="com.huizhi.admin.action.FindAllAdminAction" method="findAllAdmin"> <result name="success">/admin/alladmin.jsp</result> </action> <!-- ****************************************--> <!-- 删除管理员信息 --> <action name="deleteAdmin" class="com.huizhi.admin.action.DeleteAdminAction" method="deleteAdmin"> <result name="success">/admin/succ.jsp</result> <result name="error">/error.jsp</result> </action> </package> <!-- 分——————————————————————————————————————割——————————————————————————————————————线 --> </struts>
sql文件
create database reg; create table `reg`.`users` ( `id` int not null, `username` varchar(20) not null, `password` varchar(20) not null, `name` varchar(20) not null, `nic` varchar(30) not null, `sex` char(2) not null, `age` int null, `email` varchar(30) null, `phone` varchar(20) null, `selfshow` varchar(300) null, primary key (`id`) ); create table `reg`.`admin` ( `id` int, `username` varchar(20) not null, `password` varchar(20) not null, `name` varchar(20) not null, `qx` int not null, primary key (`id`) ); select * from users; ALTER TABLE `reg`.`users` CHANGE COLUMN `id` `id` INT(11) NOT NULL AUTO_INCREMENT ; insert into `users` (`username`, `password`, `name`, `nic`, `sex`, `age`, `email`, `phone`, `selfshow`) VALUES ('e', 'er', 'qw', 'we', 'w', '1', 'we', 'r', 'www'); use reg; select * from `reg`.`users` where username = "xiaofeng"; update users set password="998", name="xiaoming", nic="xiaoxiao", sex="妖", age=998, email="dei!yaojing@163.com", phone="120110198", selfshow="嘚!妖怪!!
。哪里跑,交出命来~~~~" where username="e" and id="5"; --#关于管理员那个表的SQL语句 INSERT INTO `reg`.`admin` (`id`, `username`, `password`, `name`, `qx`) VALUES (NULL, 'xiaofeng', 'xiaofeng', 'xiaofeng', '998'); --#把id设置为自己主动增长 ALTER TABLE `reg`.`admin` change column id id int(11) not null auto_increment; select * from admin where username="xiaofeng" and password="xiaofeng"; select * from admin; INSERT INTO `reg`.`admin` (`username`, `password`, `name`, `qx`) VALUES ('xujuan', 'xujuan', 'xujuan', '2'); INSERT INTO `reg`.`admin` (`username`, `password`, `name`, `qx`) VALUES ('yanyan', 'yanyan', 'yanyan', '2'); insert into admin (`username`, `password`, `name`, `qx`) values ('X', 'X', 'X先生', '1'); insert into admin (`username`, `password`, `name`, `qx`) values ('y', 'y', 'y先生', '1'); insert into admin (`username`, `password`, `name`, `qx`) values ('z', 'z', 'z先生', '1'); delete from admin where id=7;
action包
usersaction
adminaction
dao包
usersdao
/** * 书本:【struts2】+【hibernate】+【Spring】整合开发技术具体解释 * 功能:用户注冊系统 * 文件:DatabaseDAO.java * 时间:2014年11月11日21:36:01 * 作者:cutter_point */ package com.huizhi.users.dao; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import com.huizhi.database.DatabaseDAO; import com.huizhi.vo.Users; public class UsersDAO { private Connection con; //定义连接对象 private PreparedStatement pt; //定义预处理对象 private ResultSet rs; //定义结果集对象 //更新数据的方法 public int update(Users users) { int i = 0; con = DatabaseDAO.getConnection(); //获得连接对象 String sql = "update users set password=?, name=?, nic=?, sex=?, age=?, email=?
, phone=?
, "+ "selfshow=? where username=?
and id=?;"; try { //得到
标签:.net 设置 err get code constant password array ring
原文地址:http://www.cnblogs.com/slgkaifa/p/7380999.html