struts2
来源:互联网 发布:雷蛇云驱动mac版怎么用 编辑:程序博客网 时间:2024/05/01 02:15
第一种在action里面定义属性,自动生成get和set方法,struts2会自动set进去。
页面请求url为:http://localhost:/xxx/xxx?name=xxx
第二种为在action里面定义model或者dto(vo/do),自动生成get和set方法,struts2会自动set进去。这种是最常用的,推荐使用。。。
页面请求url为:http://localhost:/xxx/xxx?user.name=xxx
第三种实现ModelDriven,需要new对象,最不常用。。。
- public class UserAction extends ActionSupport {
- private String name;
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- ...
- }
页面请求url为:http://localhost:/xxx/xxx?name=xxx
第二种为在action里面定义model或者dto(vo/do),自动生成get和set方法,struts2会自动set进去。这种是最常用的,推荐使用。。。
- public class UserAction extends ActionSupport {
- private User user;
- public User getUser() {
- return user;
- }
- public void setUser(User user) {
- this.user = user;
- }
- ...
- }
- public class User {
- private String name;
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- }
页面请求url为:http://localhost:/xxx/xxx?user.name=xxx
第三种实现ModelDriven,需要new对象,最不常用。。。
- public class UserAction extends ActionSupport implements ModelDriven<User>{
- private User user = new User();
- @Override
- public User getModel() {
- return user;
- }
- ...
- }
- public class User {
- private String name;
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- }
0 0
- Struts2
- struts2
- struts2
- Struts2
- struts2
- struts2
- Struts2
- struts2
- struts2
- struts2
- Struts2
- Struts2
- Struts2
- struts2
- struts2
- STRUTS2
- Struts2
- Struts2
- 蓝桥杯 历届试题 错误票据
- 匹配URL路径执行指定Controller
- jquery清空form表单
- php 正则字符汇总
- 正则表达式使用
- struts2
- xcode7接入iOS友盟分享问题处理
- 欢迎使用CSDN-markdown编辑器
- struts2 配置文件
- Hashmap的简单使用
- Groovy笔记
- IOS加密api数据接口
- 推荐几款实用的Android Studio 插件
- Json学习