Search code examples
jqueryajaxstruts-1

jQuery modal form AJAX to Struts 1.3 Action


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! :)


Solution

  • 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