关于ognl的问题
对应的java文件:
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import com.opensymphony.xwork2.ActionSupport;
public class OGNL extends ActionSupport{
private static final long serialVersionUID = 1L;
private String username;
private Cat cat;
private String password;
private ArrayList<Integer> user = new ArrayList<Integer>();
private Set<String> set = new HashSet<String>();
private Map<String, String> map = new HashMap<String, String>();
public OGNL(){
user.add(1);
user.add(1);
user.add(2);
user.add(3);
user.add(4);
set.add("set1");
set.add("set2");
set.add("set3");
set.add("set4");
map.put("map1", "map1value");
map.put("map2", "map2value");
map.put("map3", "map3value");
}
public ArrayList<Integer> getUser() {
return user;
}
public void setUser(ArrayList<Integer> user) {
this.user = user;
}
public Set<String> getSet() {
return set;
}
public void setSet(Set<String> set) {
this.set = set;
}
public Map<String, String> getMap() {
return map;
}
public void setMap(Map<String, String> map) {
this.map = map;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Cat getCat() {
return cat;
}
public void setCat(Cat cat) {
this.cat = cat;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String mm(){
return "mm";
}
public String execute() throws Exception {
return SUCCESS;
}
}
当我在jsp中写入这样的话时:<s:property value="user.{?#this>6}==null"/><br>在网页中居然显示false,我在user这个list中只放入了1,2,3,4的嘛,那么应该是空集合啥,为什么我在写投影的时候this>(任何数字)都是false啊,
------解决方案--------------------楼主只需要把表达式稍微改动一下应该就能找到原因了吧。
XML code
<s:property value="user.{?#this>6}" />
------解决方案--------------------
------解决方案--------------------
------解决方案--------------------
------解决方案--------------------
------解决方案--------------------
没见过这种表达式
------解决方案--------------------