提交参数后,使用不含Ajax的百里香刷新页面

时间:2019-07-12 08:30:07

标签: spring-boot thymeleaf

我仅从前端发送一个参数:

<form th:action="@{/unblock-user}" method="get">
<input type="email" name="email"  class="form-control" onchange="this.form.submit(); location.reload();" />
<button type="submit" class="btn btn-success">Search</button>

到后端:

@GetMapping("/unblock-user")
public ResponseEntity unblockInternalUser(
        @RequestParam("email") String email
)  {

    boolean isProcessDone = service.doTheJob( email);

    return new ResponseEntity(isProcessDone ? HttpStatus.OK : HttpStatus.NOT_FOUND);
}

如果HttpStatus.OK,则应刷新页面。如果没有,它应该显示一条消息。没有AJax怎么办?

这也得到了看法:

  @GetMapping("unblock-user-view")
    public ModelAndView getUnblockUserView() {

        ModelAndView modelView = new ModelAndView();

        modelView = prepareModelAndView("unblock-user");

        return modelView;
    }

现在,如果处理成功,则转到

http://localhost:8090/unblock-user?email=xxx%40qq.co.uk

无需刷新。

0 个答案:

没有答案