Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8688843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:28:48+00:00 2026-06-12T23:28:48+00:00

First of all I am mainly with a JSF background. I have started recently

  • 0

First of all I am mainly with a JSF background.

I have started recently studying Spring MVC. One thing that is bothering me is the ajax re-rendering when using Spring MVC and JQuery.

Let’s imagine that I have defined a complex form in my people.jsp view:

<c:forEach var="person" items="${people}">
   <table>
       <tr class="trPersonClass">...</tr>
       <tr>...</tr>
   </table>
</c:forEach>

And I have a refresh button below. When the refresh button is clicked I want with ajax the people to rerender.

function refreshButtonClicked() {
    $.ajax({
       type: "GET",
       url: "ajax/loadPeople.do"
    }).done(function( msg ) {   
        //WHAT SHOULD I DO HERE???            
    } 
});

So what I should do there? I have already defined how the people rendering should like with the c:forEach tag in my jsp. I don’t want to repeat it again. I don’t want to duplicate user interface code at both places – in the JQuery done callback and with JSP tags in my views. This is error prone in my opinion.

Please explain me kindly what I am missing here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T23:28:50+00:00Added an answer on June 12, 2026 at 11:28 pm

    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.

    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.

    More details on ViewResolver can be found here: http://static.springsource.org/spring/docs/3.0.x/reference/mvc.html

    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:

    @RequestMapping("/table")
    public ModelAndView renderTable() {
       List<People> people = peopleService.findAllPeople();
       return new ModelAndView("/people", "people", people);
    }
    

    I’m also assuming you have another handler that returns the main page where the table is embedded via ajax.

    <body>
        ...
        /* Content of div will be populated via ajax*/
        <div id="myTableContainer" />
        ...
    </body>
    

    The javaScript for this would be something like:

    $(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);
      });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First of all, apologize because I have seen some posts about this, but I
First of all I want to mention two things, One: My code isn't perfect
First of all, let me say that I am not a professional coder -
I have been doing a lot of research on MVC and file structure. Mainly
First of all my apologies to those of you who would have followed my
I have several modules (mainly C) that need to be redesigned (using C++). Currently,
Dev-C++ was one of the first IDEs that I got my hand on long
E.g. I have a div that contains all the text like: <div class=text-container> <p>
First of all i have the following to convert my Javascript array to a
I have a problem in Entity-Framework, using Code-First, that I couldn't solve. Having entities

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.