jQuery modal form AJAX to Struts 1.3 Action

折月煮酒 提交于 2019-12-25 02:39:12

问题


Making a new question, as was suggested to me.

I'm trying to send data from a jQuery UI modal form to a Struts ActionForm using AJAX. The URL looks something like this (using HTTP GET):

localhost.../insertVenue.do?param1=param1&param2=param2...

However, when I try to to do this I get 404 not found. /insertVenue.do is found, but not the URL with the extra parametres.

Hope anyone can shed some light on the issue!

This is what my struts-config.xml looks like (for the specific action):

<action path="/registered/insertVenue" type="actions.InsertVenueAction" name="venueFormInsert"></action>

Thanks! :)


回答1:


You must define a Form Bean to carry the values of your parameters in your struts-config.xml. In your example above you have mentioned "venueFormInsert". You'll want something like this...

<form-beans>
    <form-bean name="venueFormInsert" type="forms.venueFormInsert" />
</form-beans>

Then define this Java Bean to match your expected parameters

public class JmsMessageForm extends ActionForm {

    private String id;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }   
}

Other than that you havent stated what the actual URL you are using. It must have the context root included and the "path" you listed above from your struts-config.xml. So something like this if your appication's context root is called "myapp" when deployed...

http://server.acme.com/myapp/registered/insertVenue.do?id=5

This venueFormInsert bean will then be passed automatically to your action handler InsertVenueAction.execute() and be populated with the URL parameters passed in




回答2:


your url is not well formatted.

localhost.../insertVenue.do?param1=param1?param2=param2..

must be like

localhost.../insertVenue.do?param1=param1&param2=param2..


来源:https://stackoverflow.com/questions/8223167/jquery-modal-form-ajax-to-struts-1-3-action

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!