我想从Spring MVC框架服务类向客户端发送消息,如代码
@Override
public void updateBoard(Map<String, Object> map) throws Exception {
String password = boardDAO.selectPassword(map);
if (!password.isEmpty() && !password.equals(map.get("PASSWORD"))) {
return;
}else {
//TODO need to send message to client when password is wrong
}
updatelogDAO.insertUpdateLog(map);
boardDAO.updateBoard(map);
}
如何在 Spring MVC 中向客户端发送消息服务器'服务'?
答案 0 :(得分:1)
尝试使用ModelAndView
,如下所示:
return new ModelAndView("password", "messageError", password);
或者像这样使用Model
:
public void updateBoard(Map<String, Object> map, Model model) {
model.addAttribute("passwordError", message);
....