在Struts2标记中评估变量时的警告

时间:2012-11-30 10:39:47

标签: struts2 tags javabeans evaluation ognl

当我要在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;
    }

}

0 个答案:

没有答案