0

当我必须在 struts 标记中显示 bean 属性时,我遇到了问题。我将 log4j 设置为调试模式,当我使用 OGNL 表达式评估 bean 时,我在屏幕上得到了正确的值,但我也在控制台中得到了很多警告。这是代码:

<s:textfield id="citta" name="citta" value="%{add.citta}" />

或另一个例子:

<s:if test="%{add.citta != null}" > ... </s:if>

显示了值 add.citta,但在控制台中我得到:

DEBUG [http-bio-8080-exec-2] (CommonsLogger.java:68) - Entering getProperty (ognl.OgnlContext@b07b029a,org.apache.struts2.util.AttributeMap@ac995a,templateDir)
 - [2012-11-30 10:52:43,150]DEBUG [http-bio-8080-exec-2] (CommonsLogger.java:68) - Entering nullPropertyValue [target=[it.consoft.controller.GestioneAddress@4d92da, com.opensymphony.xwork2.DefaultTextProvider@b39ad9], property=templateDir]
 - [2012-11-30 10:52:43,153]DEBUG [http-bio-8080-exec-2] (CommonsLogger.java:68) - Entering nullPropertyValue [target=[it.consoft.controller.GestioneAddress@4d92da, com.opensymphony.xwork2.DefaultTextProvider@b39ad9], property=templateDir]
 - [2012-11-30 10:52:43,155]DEBUG [http-bio-8080-exec-2] (CommonsLogger.java:68) - Entering nullPropertyValue [target=org.apache.struts2.util.AttributeMap@ac995a, property=templateDir]
 - [2012-11-30 10:52:43,157]DEBUG [http-bio-8080-exec-2] (CommonsLogger.java:68) - Property: null
 - [2012-11-30 10:52:43,159]DEBUG [http-bio-8080-exec-2] (CommonsLogger.java:68) - Class: com.opensymphony.xwork2.util.CompoundRoot
 - [2012-11-30 10:52:43,160]DEBUG [http-bio-8080-exec-2] (CommonsLogger.java:68) - field-level type converter for property [null] = none found
 - [2012-11-30 10:52:43,162]DEBUG [http-bio-8080-exec-2] (CommonsLogger.java:68) - global-level type converter for property [null] = none found
 - [2012-11-30 10:52:43,163]DEBUG [http-bio-8080-exec-2] (CommonsLogger.java:68) - falling back to default type converter [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter@b5c55e]
 - [2012-11-30 10:52:43,165]DEBUG [http-bio-8080-exec-2] (CommonsLogger.java:68) - Entering getProperty (ognl.OgnlContext@b07b029a,org.apache.struts2.util.AttributeMap@ac995a,theme)
 - [2012-11-30 10:52:43,167]DEBUG [http-bio-8080-exec-2] (CommonsLogger.java:68) - Entering nullPropertyValue [target=[it.consoft.controller.GestioneAddress@4d92da, com.opensymphony.xwork2.DefaultTextProvider@b39ad9], property=theme]
 - [2012-11-30 10:52:43,169]DEBUG [http-bio-8080-exec-2] (CommonsLogger.java:68) - Entering nullPropertyValue [target=[it.consoft.controller.GestioneAddress@4d92da, com.opensymphony.xwork2.DefaultTextProvider@b39ad9], property=theme]
 - [2012-11-30 10:52:43,171]DEBUG [http-bio-8080-exec-2] (CommonsLogger.java:68) - Entering nullPropertyValue [target=org.apache.struts2.util.AttributeMap@ac995a, property=theme]
 - [2012-11-30 10:52:43,173]DEBUG [http-bio-8080-exec-2] (CommonsLogger.java:68) - Property: null
 - [2012-11-30 10:52:43,175]DEBUG [http-bio-8080-exec-2] (CommonsLogger.java:68) - Class: com.opensymphony.xwork2.util.CompoundRoot
 - [2012-11-30 10:52:43,176]DEBUG [http-bio-8080-exec-2] (CommonsLogger.java:68) - field-level type converter for property [null] = none found
 - [2012-11-30 10:52:43,176]DEBUG [http-bio-8080-exec-2] (CommonsLogger.java:68) - global-level type converter for property [null] = none found
 - [2012-11-30 10:52:43,177]DEBUG [http-bio-8080-exec-2] (CommonsLogger.java:68) - falling back to default type converter [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter@b5c55e]
 - [2012-11-30 10:52:43,178]DEBUG [http-bio-8080-exec-2] (CommonsLogger.java:68) - Entering nullPropertyValue [target=[it.consoft.controller.GestioneAddress@4d92da, com.opensymphony.xwork2.DefaultTextProvider@b39ad9], property=registrazione]
 - [2012-11-30 10:52:43,180]DEBUG [http-bio-8080-exec-2] (CommonsLogger.java:68) - Entering getProperty (ognl.OgnlContext@b07b029a,org.apache.struts2.util.AttributeMap@ac995a,citta)
 - [2012-11-30 10:52:43,184]DEBUG [http-bio-8080-exec-2] (CommonsLogger.java:68) - Entering getProperty (ognl.OgnlContext@b07b029a,org.apache.struts2.util.AttributeMap@ac995a,templateDir)
 - [2012-11-30 10:52:43,185]DEBUG [http-bio-8080-exec-2] (CommonsLogger.java:68) - Entering nullPropertyValue [target=[it.consoft.controller.GestioneAddress@4d92da, com.opensymphony.xwork2.DefaultTextProvider@b39ad9], property=templateDir]
 - [2012-11-30 10:52:43,186]DEBUG [http-bio-8080-exec-2] (CommonsLogger.java:68) - Entering nullPropertyValue [target=[it.consoft.controller.GestioneAddress@4d92da, com.opensymphony.xwork2.DefaultTextProvider@b39ad9], property=templateDir]
 - [2012-11-30 10:52:43,187]DEBUG [http-bio-8080-exec-2] (CommonsLogger.java:68) - Entering nullPropertyValue [target=org.apache.struts2.util.AttributeMap@ac995a, property=templateDir]
 - [2012-11-30 10:52:43,188]DEBUG [http-bio-8080-exec-2] (CommonsLogger.java:68) - Property: null

我想修复它,我也尝试过声明一个变量,<s:set> or <s:bean>但警告没有消失。

这是我的课:

public class GestioneAddress extends ActionSupport {

    private Address add;

public Address getAdd() {
        return add;
    }


    public void setAdd(Address add) {
        this.add = add;
        }
}

这是我的豆子:

public class Address implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "AddressID")

    private Integer addressID;

    @Basic(optional = false)
    @Size(min = 1, max = 45)
    @Column(name = "Citta")

    private String citta;



    public Integer getAddressID() {
        return addressID;
    }

    public void setAddressID(Integer addressID) {
        this.addressID = addressID;
    }

    public String getCitta() {
        return citta;
    }

    public void setCitta(String citta) {
        this.citta = citta;
    }

}
4

0 回答 0