Spring MVC 4 and Thymeleaf - Prevent page refresh

前端 未结 3 950
再見小時候
再見小時候 2021-01-20 04:55

I promise, I have Googled the heck out of this.

I have a Spring MVC 4 app that uses Thymeleaf to collect form data and put it into a database. Works very well, exce

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-20 05:35

    So thymeleaf will render the page as a HTML and sends it to client to display, if you want to be able to submit form data to controller without changing pages you need to incorporate Javascript.

    You definitely need to use javascript/ajax to post the form contents and keep the page as it is.

    If you want to update just the section that contains the form for example what you can do is make a call to a controller method that returns a fragment and display the fragment containing the relevant form information.

提交回复
热议问题