I am working on a platform, with comments, messages etc... Surprisingly, I can't find the answer anywhere!
I'm trying to keep the same position of the page after a post method, and when I return a jsp
from the controller
.
The problem is, whenever I send a message for an example, or post a comment, the page returns, but returns in the top position which is annoying and ineffective.
How can I keep the page and scroll at the same position after returning or redirecting from the controller?
I'll post some example code:
@RequestMapping(value = "/{recipient}", method = RequestMethod.POST)
public String chatPost(@PathVariable("recipient") String recipient, @ModelAttribute("message") Message message, Model model, Principal principal) {
Date date = new Date();
message.setCreationDate(date);
Profile recipientObj = profileService.getProfileByUsername(recipient);
messageService.sendMessageTo(message, recipientObj);
return "redirect:/message/" + recipient;
}