Note that there are some explanatory texts on larger screens.

plurals
  1. POSubmit form without refreshing (SPRING MVC 3)
    text
    copied!<p>Is it possible to submit a form in SPRING MVC 3 without refreshing?</p> <p>What i want is to store the data in the SPRING form to java <strong>object/POJO.</strong> </p> <p>Here is my <strong>map.jsp</strong></p> <pre><code>&lt;form:form action="" method="post" commandName="userQuery"&gt; &lt;form:input path="startLocation" id ="startLocation" /&gt; &lt;input type="submit" value="Search" onclick="codeAddress()"&gt; &lt;script type="text/javascript"&gt; function codeAddress(){ var address = document.getElementById("startLocation").value; geocoder.geocode( { 'address': address, 'partialmatch' : true }, geoCodeResults ); &lt;/script&gt; </code></pre> <p>I am trying to store the data (i.e startLocation ) to a java object, <strong>AT THE SAME TIME</strong> use that data for javascript so i can display the google map and display the marker on that location. BUT every time i submit the form, it refreshes the page, thus the MARKER is not rendered because it reloads the whole page including the map</p> <p>Here is my <strong>Controller.java</strong> </p> <pre><code>@RequestMapping(value= "/map" , method = RequestMethod.GET) public ModelAndView showMap(){ ModelAndView mav = new ModelAndView("home/map"); Query query = new Query(); mav.getModel().put("userQuery", query); return mav; } @RequestMapping(value="/map", method = RequestMethod.POST) public ModelAndView createMap(@ModelAttribute("userQuery") Query query ){ ModelAndView mav = new ModelAndView("home/map"); List&lt;Query&gt; q = new ArrayList&lt;Query&gt;(); q.add(new Query(query.getStartLocation())); mav.addObject("q", q); return mav; } </code></pre> <p>I need to store the <strong>startLocation</strong>. please help. are there alternative way to store the user input other than SPRING forms? </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload