controller代碼如下
ModelAndView modelAndView = new ModelAndView("/xxx/xxx.jsp");
modelAndView.addObject("message", "success");
return modelAndView;
JSP文件書寫如下,寫於head標籤內即可
<%
if((String)request.getAttribute("message") != null) {
%>
<script type="text/javascript" language="javascript">
alert("添加成功,跳轉到信息列表!"); // 彈出錯誤信息
window.location='http://localhost:8080/xxx/xxx.action' ; // 跳轉到登錄界面
</script>
<%
}
%>