奇怪的Java bug我似乎无法解决

时间:2011-11-22 12:20:19

标签: java web-applications coding-style struts-1

我正在摸不着为什么我的try语句中的某些代码没有被执行。以下是有问题的罪魁祸首。

try {
    Long idSociety = UtilAction.<Long>getSessionAttribute(session, idSocietyAttrName);
    ContactAddressForm caf = (ContactAddressForm) form;
    java.lang.System.out.println("invoiceAddresss: " + caf.getInvoiceAddress()); //This doesn't show in Console
    Address address = new Address(caf.getStreet(), caf.getPostalCode(), caf.getCity(), caf.getBoitePostale());
    ContactAddress ca = new ContactAddress();

    ca.setInvoiceAddress(caf.getInvoiceAddress()); //Not set despite the Debugger showing the correct value for caf.
    ca.setAddress(address); //But this is set 0_o?
    synchronized (session) {
        SocietyPeer.storeAddress(idSociety, ca);
    }
    addAddressesInSession(session, idSociety);
    form.reset(mapping, request);
}

ContactAddress类

package fr.model.society;

import fr.model.component.Address;

public class ContactAddress {

    private Long idContactAddress;

    private Address address;
    private Boolean invoiceAddress = false;

    private Society society;

    public Long getIdContactAddress() {
        return idContactAddress;
    }

    public void setIdContactAddress(Long id) {
        this.idContactAddress = id;
    }

    public Address getAddress() {
        return address;
    }

    public void setAddress(Address address) {
        this.address = address;
    }

    public void setInvoiceAddress(Boolean invoiceAddress) {
        this.invoiceAddress = invoiceAddress;
    }

    public Boolean getInvoiceAddress() {
        return invoiceAddress;
    }

    /**
     * **************** METHODES MAPPING *****************
     */
    public Society getSociety() {
        return society;
    }

    public void setSociety(Society society) {
        this.society = society;
    }

    public String toString() {
        return getAddress().toString();
    }

    public boolean equals(Object o) {
        if (!(o instanceof ContactAddress)) {
            return false;
        }
        ContactAddress ca = (ContactAddress) o;
        return address.equals(ca.getAddress()) && (getSociety().equals(ca.getSociety()));
    }

    public int hashCode() {
        return ((getIdContactAddress() == null) ? 0 : getIdContactAddress().hashCode())
                ^ address.hashCode()
                ^ ((getSociety() == null) ? 0 : getSociety().hashCode());
    }
}

编辑: 基本上我正在尝试设置invoiceAddress布尔变量,并且我目前无法实现所有意图和目的。控制台中没有打印 java.lang.System.out.println(“invoiceAddresss:”+ caf.getInvoiceAddress()); 我也尝试将其传递给temp boolean变量,并且根本没有在调试器中拾取该变量。

1 个答案:

答案 0 :(得分:0)

我在Netbeans中加载了这个项目,这个问题似乎与eclipse和Tomcat服务器有关。尽管重建,但不得更新Warfile。