一:属性方法
1.在action中增加属性及get()和set()方法,只接使用属性
路径方问时加参数:http://127.0.0.1:8080/Struts2_0100_Introduction/extends_add?username=100
二:域模型(domain方式)
1.在action中增加模型对象,及get()和set()方法。
2.在模型对象增加属性及及get()和set()方法。
路径方问时加参数:http://127.0.0.1:8080/Struts2_0100_Introduction/extends_add?user.username=100
三:ModelDriven方式
1.在action实现ModelDriven<User>,覆盖方法
[quote]
public User getModel() {
return user;
}
[/quote]
2.创建属性,private User user = new User();
http://127.0.0.1:8080/Struts2_0100_Introduction/extends_add?username=100
1.在action中增加属性及get()和set()方法,只接使用属性
路径方问时加参数:http://127.0.0.1:8080/Struts2_0100_Introduction/extends_add?username=100
二:域模型(domain方式)
1.在action中增加模型对象,及get()和set()方法。
2.在模型对象增加属性及及get()和set()方法。
路径方问时加参数:http://127.0.0.1:8080/Struts2_0100_Introduction/extends_add?user.username=100
三:ModelDriven方式
1.在action实现ModelDriven<User>,覆盖方法
[quote]
public User getModel() {
return user;
}
[/quote]
2.创建属性,private User user = new User();
http://127.0.0.1:8080/Struts2_0100_Introduction/extends_add?username=100
本文介绍了Struts2框架中三种不同的参数接收方法:属性方法、域模型(domain)方式和ModelDriven方式,并提供了具体的实现步骤及访问路径示例。
161

被折叠的 条评论
为什么被折叠?



