Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First of all, Spring MVC is very flexible. You can have backend handlers that return HTML generated by a view engine, you can have a handlers that returns JSON/XML/ProtocolBuffers/etc. and use client side rendering engines like Mustache etc. to display the page in the browser, or you can combine the two in the same application.</p> <p>If you want to generate HTML on the server, Spring MVC allows you to use different template engines to do that. You can use JSP, Freemarker, Velocity etc. In order to do that, it uses a ViewResolver abstraction, and in your code you only have to deal with the ModelAndView API.</p> <p>More details on ViewResolver can be found here: <a href="http://static.springsource.org/spring/docs/3.0.x/reference/mvc.html" rel="nofollow">http://static.springsource.org/spring/docs/3.0.x/reference/mvc.html</a></p> <p>Based on your question it sounds like you have a backend that use JSP to create the html server side. In order to update only the table and not reload the entire page when a user clicks a refresh button, you could for example have a handler that returns only the html table like so:</p> <pre><code>@RequestMapping("/table") public ModelAndView renderTable() { List&lt;People&gt; people = peopleService.findAllPeople(); return new ModelAndView("/people", "people", people); } </code></pre> <p>I'm also assuming you have another handler that returns the main page where the table is embedded via ajax.</p> <pre><code>&lt;body&gt; ... /* Content of div will be populated via ajax*/ &lt;div id="myTableContainer" /&gt; ... &lt;/body&gt; </code></pre> <p>The javaScript for this would be something like:</p> <pre><code>$(function() { var myTableContainer = $("#myTableContainer"); var renderTable = function(container) { $.get("/table", function(data) { container.empty().html(data); } }; /* This is called on document ready */ renderTable(myTableContainer); /* Use the same renderTable function when the refresh button is clicked */ $("#refreshButton").click(function() { renderTable(myTableContainer); }); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

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