求完整代碼
創(chuàng)新互聯(lián)專業(yè)為企業(yè)提供順平網(wǎng)站建設(shè)、順平做網(wǎng)站、順平網(wǎng)站設(shè)計、順平網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計與制作、順平企業(yè)網(wǎng)站模板建站服務(wù),10年順平做網(wǎng)站經(jīng)驗,不只是建網(wǎng)站,更提供有價值的思路和整體網(wǎng)絡(luò)服務(wù)。
employee.setId(1); //此時得到id號為1的員工(這里我認為得到的是包括id號為1的員工的所有信息)
我不清楚這是為什么
首先在任一目錄保存以下代碼
編譯代碼:javac PersonInfo.class
執(zhí)行代碼:java PersonInfo
代碼輸出效果如下:
id = 001, name = 張三, sex = 男, 年齡 = 12, 身份證 = 140421198809021102
id = 002, name = 李四, sex = 女, 年齡 = 25, 身份證 = 280421198809022103
id = 003, name = 王五, sex = 男, 年齡 = 33, 身份證 = 355421198809021104
id = 004, name = 趙六, sex = 女, 年齡 = 17, 身份證 = 472421198809021105
import java.util.ArrayList;
import java.util.List;
public class PersonInfo{
private String id; //id
private String name; //姓名
private int sex; //性別
private int age; //年齡
private String idCard; //身份證
@Override
public String toString() {
return "id = " + getId() + ", name = "
+ getName() + ", sex = " + (getSex()==0?"男":"女")
+ ", 年齡 = " + getAge() + ", 身份證 = " + getIdCard();
}
public PersonInfo(String id, String name, int sex, int age, String idCard) {
this.id = id;
this.name = name;
this.sex = sex;
this.age = age;
this.idCard = idCard;
}
public static void main(String[] args) {
PersonInfo p1 = new PersonInfo("001", "張三", 0, 12, "140421198809021102");
PersonInfo p2 = new PersonInfo("002", "李四", 1, 25, "280421198809022103");
PersonInfo p3 = new PersonInfo("003", "王五", 0, 33, "355421198809021104");
PersonInfo p4 = new PersonInfo("004", "趙六", 1, 17, "472421198809021105");
ListPersonInfo personList = new ArrayListPersonInfo();
personList.add(p1);
personList.add(p2);
personList.add(p3);
personList.add(p4);
for(PersonInfo p : personList){
System.out.println(p);
}
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getSex() {
return sex;
}
public void setSex(int sex) {
this.sex = sex;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getIdCard() {
return idCard;
}
public void setIdCard(String idCard) {
this.idCard = idCard;
}
}
1.你的action方法UserServlet配置了嗎?
2. 在action里,你定義的參數(shù)是user,還是username,userPwd?
用戶名稱:input name="username" value=%=user.getUserName() %br
用戶密碼:input name="userpwd" value=%=user.getUserPwd() %br
改為
用戶名稱:input name="user.username" value=%=user.getUserName() %br
用戶密碼:input name="user.userpwd" value=%=user.getUserPwd() %br
public class MyInfo {
public static void main(String []args) {
System.out.println("你好,以下是我的個人信息:");
System.out.println("姓名:李剛");
System.out.println("性別:女");
System.out.println("出生年月:1998-08");
System.out.println("愛好:上網(wǎng)");}
}