首页>代码>ssh实现简单的网络借贷项目>/personloan/src/com/loan/action/RegisterAction.java
package com.loan.action;

import java.util.HashMap;
import java.util.Map;

import net.sf.json.JSONObject;

import org.apache.struts2.json.annotations.JSON;

import com.loan.action.base.BaseAction;
import com.loan.entity.Person;

public class RegisterAction extends BaseAction {

	/**
	 *
	 */
	private static final long serialVersionUID = 1L;

	private String u;
	private String p;
    private String result;
	public String getU() {
		return u;
	}

	public void setU(String u) {
		this.u = u;
	}

	public String getP() {
		return p;
	}

	public void setP(String p) {
		this.p = p;
	}
    @JSON()
	public String getResult() {
	    return result;
	}

    public void setResult(String result) {
        this.result = result;
    }
    	
    /**
     * 验证用户名是否存在
     */
	@Override
	public String execute() throws Exception {
		Map<String,Object> map = new HashMap<String,Object>();
		JSONObject json = null;
		if(mgr.validateName(u,"login")){
			  map.put("rcode", "0");
		}else{
			map.put("rcode", "1");
		}
		json = JSONObject.fromObject(map);
		result = json.toString();//给result赋值,传递给页面
		return SUCCESS;
	}
	
	/**
	 * 保存注册用户信息
	 * @return
	 * @throws Exception
	 */
	public String save() throws Exception {
		Person person = new Person();
		person.setPassword(p);
		if(u.contains("@") || u.contains(".")){
			person.setEmail(u);
		}else{
			person.setTelephone(u);
		}
		if(mgr.addUser(person) > 0){
			return SUCCESS;
		}
		return "fail";
	}
}
最近下载更多
JohnAlex  LV9 2022年2月19日
wanglinddad  LV54 2021年12月5日
1029162867  LV13 2021年9月25日
ericxu1116  LV24 2021年5月20日
ym111111111  LV3 2021年3月18日
王伟杰  LV2 2021年2月25日
clz123456  LV6 2020年12月21日
yguyue  LV8 2020年12月15日
ExamplesDYC  LV13 2020年11月21日
wxx001  LV10 2020年10月24日
最近浏览更多
WBelong  LV7 3月8日
2017143155  LV12 2023年5月22日
泓鼎168  LV19 2023年3月30日
95959595959  LV13 2023年2月13日
upup996  LV6 2022年12月14日
uni-code_0123  LV1 2022年11月16日
maniheim  LV7 2022年9月30日
wjh12345654321  LV14 2022年8月2日
折叠门 2022年7月6日
暂无贡献等级
liangge2115  LV27 2022年6月29日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友