浏览 1668 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2010-01-28
最后修改:2010-01-28
先看总体分包情况,现在所有配置文件都写在WEB-INF下,如果要写在src的某个包下的话要改变一下路径。 以前项目经理用经验跟我们说,开发一般是从后台到前台,所以,我先从后台的代码发起。 建表语句: drop database if exists zhiming; create database zhiming; use zhiming; create table z_user ( id int(11) not null primary key auto_increment, name varchar(32) not null, sex varchar(32) not null, age varchar(32) not null, address varchar(100) default null, phone varchar(32) not null, email varchar(50) default null ); insert z_user values (1,'musoon','male','23','广州天河珠江新城','13600000000','musoon@126.com'); insert z_user values (2,'li','female','22','广州白云区','13600000000','li@126.com'); select * from z_user; POJO类,User.java: /** * File Name:User.java * Version: * Date:2010-1-3 * Copyright Belongs To Musoon Corporation 2010 */ package com.vo; import java.io.Serializable; /** * Project Name:ZhiMing ** Class Name:User * Author:Musoon ** Created Time:2010-1-3 下午08:37:31 * Changed By:Musoon ** Changed Time:2010-1-3 下午08:37:31 * Changed Memo: * @version * Class Description: */ public class User implements Cloneable, Serializable { private static final long serialVersionUID = -9103289450003300385L; private int id; private String name; private String sex; private String age; private String address; private String phone; private String email; /* public void clear() { id = 0; name = null; sex = null; age = null; address = null; phone = null; email = null; } public User() { this.clear(); }*/ public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getSex() { return sex; } public void setSex(String sex) { this.sex = sex; } public String getAge() { return age; } public void setAge(String age) { this.age = age; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } } 对应的sqlMap,User_sqlMap.xml: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd"> <sqlMap> <typeAlias alias="user" type="com.vo.User"/> <insert id="saveUser" parameterClass="user"> <selectKey keyProperty="id" resultClass="int"> <![CDATA[ select (max(id)+1) as value ]]> </selectKey> <![CDATA[ insert int z_user(name,sex,age,address,phone,email) values(#name#,#sex#,#age#,#address#,#phone#,#email#) ]]> </insert> <delete id="deleteUser" parameterClass="int"> <![CDATA[ delete from z_user where id=#id# ]]> </delete> <select id="getAllUsers" resultClass="user"> <![CDATA[ select * from z_user ]]> </select> <update id="updateUser" parameterClass="user"> <![CDATA[ update z_user set name=#name#, sex=#sex#, age=#age#, address=#address#, phone=#phone#, email=#email# where id=#id# ]]> </update> <select id="findUserById" parameterClass="int" resultClass="user"> <![CDATA[ select * from z_user where id=#id# ]]> </select> </sqlMap> 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |