Multiple result types in Struts2?

前端 未结 3 1209
孤独总比滥情好
孤独总比滥情好 2021-01-25 15:35

I have a Struts2 application where I using Tiles. How can I get multiple result types in action-mappings? because I need to set de output as JSON data, and Tiles simultaneous. I

相关标签:
3条回答
  • 2021-01-25 15:52

    To my knowledge there is no way to return multiple things simultaneously. The browser will only be expecting one thing, either the JSON or the HTML once all the tiles stuff is done.

    I can think of two ways to do this: double request (one for each result type) or use one to generate the other (get the JSON and use JavaScript to construct the HTML on the client).

    What are you trying to accomplish that you need both results?

    0 讨论(0)
  • 2021-01-25 15:53

    create a new result type for Tiles+JSON & use it... you can't define 2 result types in a result tag.

    0 讨论(0)
  • 2021-01-25 15:58

    How about if u have 2 diff results?!

    <result name="successJSON" type="json"/>
    
    <result name="successTiles" type="tiles">tiles.home</result>
    

    then in your server code u just route to the right one?!

    0 讨论(0)
提交回复
热议问题