Struts2 Action execution and response through AJAX

前端 未结 1 750
伪装坚强ぢ
伪装坚强ぢ 2020-12-10 22:40

I am trying to send an AJAX post request via jQuery to a Struts2 action class for processing a form and receiving JSON response, but I haven\'t figured out how to do it.

相关标签:
1条回答
  • 2020-12-10 23:23

    Sending Ajax request is so easy with Struts2 via the integration of jQuery into framework that could be used for processing a form and doing some validations of data.

    You don't need to do much just put a jQuery plugin to your project. Receiving JSON response also easy with Struts2 via the integration of JSON plugin. The JSON plugin adds a JSON result type to the project that could be used to return JSON response.

    If you are using servlet to validate and execute methods of the action class you can't use the features provided by the framework, i.e. plugins and you have to do it yourself on your own risk.

    If you don't want to use the Struts2 validation framework, so how would you like to get action errors or action messages that you didn't use? These action errors and action messages are just simple collections that contain text. So, you could return them via Ajax without any problem.

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