Org.apache.struts2.json.annotations.JSON does not show the correct format

My web application uses struts2-json-plugin-2.2.1

I have an action that provides an object loaded from the database (via sleep mode).

This object contains the java.util.Date field, which is annotated like this:

  @JSON(format = "dd-MM-yyyy") @Column(name = "DATA_CREAZIONE", nullable = false) public Date getDataCreazione() { return this.dataCreazione; } 

Instead of getting:

 "dataCreazione":"15-02-2013" 

I get this:

 "dataCreazione":"2013-02-15T16:51:06" 

In debugging, I notice that the org.apache.struts2.json.JSONWriter class does not find any annotation using the getDataCreazione method and that the proxy class is of type "$$_javassist" and not "$$EnhancerByCGLIB$$" like other cases. ..

In the same application, I have many such situations, and the annotation works fine. I don't understand what the problem (or difference) is with other classes.

Do you have any suggestions?

+4
source share
2 answers

btw I confirm the origin of my problem. As I said, it is in the proxy class that is used. In my case - if I download the object (via sleep mode), then the proxy server used is $$ _ javassist - if I get the object (through sleep mode) then the object isn’t a proxy and then JSonWriter can resume annotation β†’, so that it can format as I annotated -

0
source

You did not specify a name the annotation attribute. By default, annotations with empty names are not deserialized. For more links, check out the Apache docs .

0
source

All Articles