package com.al.action;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.al.entity.Dog;
import com.al.entity.User;
import com.opensymphony.xwork2.ActionSupport;
public class OgnlAction extends ActionSupport {
private String username;
public static int temp = 10;
private User user;
private List<User> list = new ArrayList<User>();
private Set<User> set = new HashSet<User>();
private Map<String,User> map = new HashMap<String, User>();
public String test(){
User u1 = new User();
u1.setName("tom");
u1.setAge(1);
Dog d1 = new Dog();
d1.setType("aaa");
u1.setDog(d1);
User u2 = new User();
u2.setName("jerry");
u2.setAge(2);
Dog d2 = new Dog();
d2.setType("bbb");
u2.setDog(d2);
User u3 = new User();
u3.setName("kiki");
u3.setAge(3);
Dog d3 = new Dog();
d3.setType("ccc");
u3.setDog(d3);
list.add(u1);
list.add(u2);
list.add(u3);
set.add(u1);
set.add(u2);
set.add(u3);
map.put("u1", u1);
map.put("u2", u2);
map.put("u3", u3);
return "success";
}
public int add(int a,int b){
return a+b;
}
public static String getString(){
return "aaa";
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public List<User> getList() {
return list;
}
public void setList(List<User> list) {
this.list = list;
}
public Set<User> getSet() {
return set;
}
public void setSet(Set<User> set) {
this.set = set;
}
public Map<String, User> getMap() {
return map;
}
public void setMap(Map<String, User> map) {
this.map = map;
}
/*public static int getTemp() {
return temp;
}
public static void setTemp(int temp) {
OgnlAction.temp = temp;
}
*/
}
package com.zl.entity;
public class Dog {
private String type;
public String talk(){
return "i am a dog";
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
package com.al.entity;
public class User {
public User(){
System.out.println("i am a user");
}
public User(String a){
System.out.println("i am a user"+a);
}
private String name;
private int age;
public static double dd = 1.2;
private Dog dog;
public static String getString(){
return "aaa";
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public Dog getDog() {
return dog;
}
public void setDog(Dog dog) {
this.dog = dog;
}
}