How to send JSON data via POST (ajax) and receive json response from Struts 2 action

后端 未结 3 1381
北海茫月
北海茫月 2020-12-22 12:19

I am trying to understand how to use JSON and in the process I\'m trying to get a JSON response from Struts2 action and display an alert for the response. For this I\'m usin

相关标签:
3条回答
  • 2020-12-22 13:05

    The problem in your Action class MeetingRecordAction, method updateAttendeesRecord is private, it should be public

    public String updateAttendeesRecord() {
        meetingRecordService.updateAttendeesRecord(attendeesListMethod(), meeting_record);
        setMyMsg("Update Successful!");
            return SUCCESS;
    }
    
    0 讨论(0)
  • 2020-12-22 13:07

    In the action configuration you should not override the default configuration from json-default package just extend it and all. Also json-default extend a struts-default, so multiple inheritance is not required.

    <package name="default" extends="json-default">
      <action name="meeting_record_form" class="com.task.action.MeetingRecordAction" method="updateAttendeesRecord">
        <result name="success" type="json" />
      </action>
    </package>
    
    0 讨论(0)
  • 2020-12-22 13:15

    I've solved my problem by adding myMsg on the json result. Thanks for all the help

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