求完整代码
创新互联专业为企业提供顺平网站建设、顺平做网站、顺平网站设计、顺平网站制作等企业网站建设、网页设计与制作、顺平企业网站模板建站服务,10年顺平做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。
employee.setId(1); //此时得到id号为1的员工(这里我认为得到的是包括id号为1的员工的所有信息)
我不清楚这是为什么
首先在任一目录保存以下代码
编译代码:javac PersonInfo.class
执行代码: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里,你定义的参数是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("爱好:上网");}
}