0

I am trying to handle multiple submit buttons in spring mvc in java. 1st Submit buttons is for Server side call and 2nd Submit button is only for Client Side call.

But here the problem here I am facing is, for both submit button, control is going to Server side . I am Using plane jsp with spring tag. Here my requirement is one submit button should work for server side & another submit button only works for client side.

CODE Snippet:

<body>
<div>
<form:form commandName="route" method="post" action="routeSave" id="route">
<div class="center">

Start:<form:input  path="start" id="start" maxlength="50"/>
End:<form:input  path="end" id="end" maxlength="50"/>
City:<form:input  path="city" id="city" maxlength="50" onchange="mapcenter()"/>
RouteName:<form:input  path="routeName" id="routeName" maxlength="50"/>
StartTime:<form:input path="startTime" id="startTime" maxlength="50"/>

<form:button value="SaveMap">Save Button</form:button>

<form:button value="SaveMap" onclick="save_map()">Save Map</form:button>
1
  • It has nothing to do with spring, you should check javascript function and ajax call to send data to server side. Commented Mar 22, 2015 at 9:19

2 Answers 2

1

A button of type="button" will not submit a form to a URL. A button of type="submit" (the default) will. So use a type="button" button for the client side action.

<form:form>

    <button type="button" name="btn1">no submit</button>

    <button type="submit" name="btn2">submit</button>

</form:form>
Sign up to request clarification or add additional context in comments.

Comments

0

You can try it with for Example jQuery:

$( "#route" ).submit(function( event ) {
    event.preventDefault();
});

The event Element has additional Information to handle it in handler-Method. See jQuery Docs.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.