Home > Mobile >  How to refresh a html page without using a html form? Tried redirect: it does not work
How to refresh a html page without using a html form? Tried redirect: it does not work

Time:06-11

I need to delete a question. By using following endpoint I can delete a question without any issue. But I need to refresh the forum.html page after deleting the question. I used "redirect:/forum.html" but it does not work.How can I refresh the forum.html

@Controller
public class ForumController {

 @PostMapping("/deleteQuestion")
    public String deleteQuestion(@RequestParam Long questionId){


        questionRepository.deleteById(questionId);


        return "redirect:/forum.html";
    }
}

CodePudding user response:

You can use javascript native function to reload your page:

window.location.reload(true)

You can use this function when your deleting request is completed as a callback.

CodePudding user response:

use jquery function for reload

location.reload(true);

or

location.replace(location.pathname);
  • Related