iteye_19582
iteye_19582
2009-09-23 14:32

struts2.1.6是不是不支持action内直接定义对象

  • struts

从页面中提交User的数据到Action中 Action 写到:
public class HelloWorld extends ActionSupport {
private String name;
private User user;

public User getUser()
{
return user;
}
public void setUser()
{
this.user = user;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String execute() {
name = "Hello, " + name + "!";
return SUCCESS;
}
}

但运行到Action是报一个错,错误信息如下:
2007-9-8 18:42:23 com.opensymphony.xwork2.util.InstantiatingNullHandler nullPropertyValue
严重: Could not create and/or set value back on to object
ognl.NoSuchPropertyException: tutorial.HelloWorld.user [java.lang.IllegalAccessException: Class ognl.OgnlRuntime can not access a member of class tutorial.HelloWorld with modifiers "private"]
at ognl.OgnlRuntime.setFieldValue(OgnlRuntime.java:1125)
at ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:77)
at ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:132)
at com.opensymphony.xwork2.util.OgnlValueStack$ObjectAccessor.setProperty(OgnlValueStack.java:68)
at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:1629)
但是我换了2.0.14的struts包这个问题就不会出现了,有没有人碰到多这个问题,产生的原因到底是什么啊?

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答