How to send javascript array to struts action by using jQuery Ajax

前端 未结 2 1453
北恋
北恋 2021-01-13 16:22

I am new to Struts 2. I want to send a javascript array to a Struts action class by using jQuery AJAX request.
The alert is working fine, the execute() is

2条回答
  •  失恋的感觉
    2021-01-13 16:25

    To use JSON with Struts2, your best option is to import the Struts2 JSON plugin.

    Then,

    1. you'll get automatic JSON conversion when exposing data from the action to the JSP, by using the Json Result as described here, BUT
    2. you'll need to include the Json Interceptor in your interceptor stack to have the JSON conversion from the JSP to the action, as described here and here.

提交回复
热议问题