一共有3中方法传递参数
第一种就是在action类里面定义参数,比如name,age,然后写好get和set方法,在输入路径的时候写一个
...projectname/namespace/action!add?name=a&age=18
这样就把2个参数给传进去了。
第二种 DomainModel
写一个类,比如User,里面装着属性等等,该写set和get方法都写好。然后另外弄一个继承ActionSupport类的action类。里面定义一个PrivateUser user;
写一个get和set方法,设定和取得user,Struts自己会帮你new对象。要调用的话就user.name,user.age。
第一种就是在action类里面定义参数,比如name,age,然后写好get和set方法,在输入路径的时候写一个
...projectname/namespace/action!add?name=a&age=18
这样就把2个参数给传进去了。
第二种 DomainModel
写一个类,比如User,里面装着属性等等,该写set和get方法都写好。然后另外弄一个继承ActionSupport类的action类。里面定义一个PrivateUser user;
写一个get和set方法,设定和取得user,Struts自己会帮你new对象。要调用的话就user.name,user.age。