Problem with Json plugin in Struts 2

前端 未结 3 1579
孤独总比滥情好
孤独总比滥情好 2020-12-03 15:34

I have the following code and I would to achieve functionality that /getJson will return user object as json and /getJson2 will return user2 as Json object.

         


        
3条回答
  •  盖世英雄少女心
    2020-12-03 16:00

    You must include all properties that you want to serialize. This includes the properties of the User class like this, for example:

    @Action(value="/getJson", results = {
            @Result(name="success", type="json",params = {
                    "includeProperties",
                    "user\.firstName, user\.lastName"})})
    

    But, another form to get this work could be using regular expressions:

    @Action(value="/getJson", results = {
            @Result(name="success", type="json",params = {
                    "includeProperties",
                    "user\..*"})})
    

    Regards.

提交回复
热议问题