Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Since you have included spring-mvc in you tags, I am assuming you would like some more information about sending information from client side to the server.</p> <p>If your are just using JSP, and a standard form, if you match the 'commandName' and the 'method' to your controller in spring, the controller will catch the parameters sent through the form: </p> <pre><code>&lt;form id="form" commandName="interceptedPath" method="post"&gt; &lt;input id="rating1" type="radio" name="rating" value="1" checked&gt;&lt;label for="rating1"&gt;1&lt;/label&gt; &lt;input id="rating2" type="radio" name="rating" value="2"&gt;&lt;label for="rating2"&gt;2&lt;/label&gt; &lt;input id="rating3" type="radio" name="rating" value="3"&gt;&lt;label for="rating3"&gt;3&lt;/label&gt; &lt;input id="rating4" type="radio" name="rating" value="4"&gt;&lt;label for="rating4"&gt;4&lt;/label&gt; &lt;input id="rating5" type="radio" name="rating" value="5"&gt;&lt;label for="rating5"&gt;5&lt;/label&gt; &lt;/form&gt; </code></pre> <pre><code> @RequestMapping(value = "/interceptedPath/", method = RequestMethod.POST) public String submit(Model model, HttpServletRequest request) { Map&lt;String, String[]&gt; parameterMap = request.getParameterMap(); String[] strings = parameterMap.get("rating") return "detailedCalc"; } </code></pre> <p>JavaScript should not be required unless you are doing something dynamic, like Ajax calls. If you do decide to use Javascript I suggest you use the <a href="http://jquery.com/" rel="nofollow" title="jQuery">jQuery</a> library: </p> <pre><code>$(document).ready(function () { $("form").submit(function () { $.post('/spring/locationOfAjaxController', $(this).serialize(), function (data) { } } } </code></pre> <p>For the code above, after the document has loaded on the client. An event is created that will catch all 'submit' actions on the "form" object (note the id for the form is "form"). Once that occurs jQuery will submit a POST to the specified URL. <code>$(this).serialize()</code> will serialize the form data into JSON, which will need to be handled by the server.</p> <p>If you want to do something using <strong>change</strong>, refer to <a href="http://api.jquery.com/change/" rel="nofollow">this reference</a>.</p> <p>You can find an excellent example of spring-mvc (without js) using maven archetype: <code>org.fluttercode.knappsack:spring-mvc-jpa-demo-archetype</code>. It will generate a basic project that has spring-mvc already set up and ready to go.</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