Spring MVC 学习笔记5 —— 实现简单的用户管理,增删改查(1)建立user model

在上一节的基础上,增加 user model, 并在对应的class代码中,利用Eclipase提供的Source - Generate Getter and Setters/  Generate Construction Using Fields...



1. 新建Package:edu.bit.model, 新建Class:" User "

package edu.bit.model;

public class User {
	private String username;
	private String password;
	private String nickname;
	private String email;
	
<span style="white-space:pre">	</span>//写到这里,Resouce - Getter and Setter/ Construction using fields,生成下面:

	public User(){
		
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getNickname() {
		return nickname;
	}

	public void setNickname(String nickname) {
		this.nickname = nickname;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public User(String username, String password, String nickname, String email) {
		super();
		this.username = username;
		this.password = password;
		this.nickname = nickname;
		this.email = email;
	}
}

2. Resouce - Getter and Setter/ Construction using fields

才得到上面的代码。


3. 创建一个UserController来得到映射。

        在Package“edu.bit.controller”中,new - class - name="UserController" - finish


4. 文件UserController.java,写代码:

@Controller, 

@RequestMapping("/users")


  


你可能感兴趣的:(Spring MVC 学习笔记5 —— 实现简单的用户管理,增删改查(1)建立user model)