0

I have a JSP page containing several divs.Is it possible to redirect using model and view from Spring to a specific div on the JSP since each of the div's represents a subpage?

    <div id="page1" class="content">
  <div class="container_12">
    <div class="grid_12">
      <div class="slider_wrapper">
        <ul class="items">
          <li> <img src="images/spacer.gif" alt="">
            <div class="caption banner">
              <h2>Let Us Show You the Way to Success</h2>
            </div>
          </li>      
        </ul>
      </div>
      <div class="socials"> <a href="#"></a> <a href="#"></a> <a href="#"></a> <a href="#"></a> </div>
    </div>
  </div>
</div>
<div id="page2" class="content">
  <div class="container_12">
    <div class="grid_12">
      <div class="slogan">
        <h3>Only Professional <a onClick="goToByScroll('page3'); return false;" href="#"><span>Services</span></a> for Our <a onClick="goToByScroll('page4'); return false;" href="#"><em>Clients</em></a></h3>
        <div class="text1"> <a href="#" class="tm_link"> Click here</a> for more info about this free website template created by TemplateMonster.com <br>
          Lorem ipsum dolor sit amet, consectetur adipiscing elit. In mollis erat mattis neque facilisis, sit amet ultricies </div>
      </div>        
      </div>
    </div>
  </div>
</div>
Tiny
  • 27,221
  • 105
  • 339
  • 599
Java Panter
  • 307
  • 2
  • 12
  • Would do you mean by "redirect using model and view from Spring to a specific div" ? Just scrolling the page so that the requested view comes at top ? – Serge Ballesta Jun 02 '14 at 10:41
  • Yeah I want the page to be automatically scrolled to a specific div. – Java Panter Jun 02 '14 at 10:48
  • For scrolling you will have to append html anchors in the url like #container_12 and your page will automatically be scrolled to that div by the browser. – Shailendra Jun 02 '14 at 11:51

1 Answers1

0

The only solution I can imagine is to add an attribute in your model to contain the name of the div to scroll to eg model.setAttribute("scroll_to", "socials"). Then in your JSP, you just have to add a piece of javascript to do the actual scroll. As a special case, if the attribute is not present, you simply do not add the javascript.

You will find details on how to scroll using javascript on the following SO posts : How do I scroll to an element using JavaScript? (generalist) and How can I scroll to a specific location on the page using jquery? (jquery specific)

Community
  • 1
  • 1
Serge Ballesta
  • 143,923
  • 11
  • 122
  • 252