public ActionForward execute(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
。。。
//
发送的信息
String msg = "alert('
操作成功!
');location.href='test.do?method=test';";
writeJsToFrontPage(response, msg);
return null;
}
/** *
向前端页面发送
javascript
脚本
* * @param response * @param text * @throws IOException */
protected void writeJsToFrontPage(HttpServletResponse response,
String msg) throws IOException {
response.setContentType("text/html; charset=utf-8");
response.setHeader("Cache-Control", "no-cache");
PrintWriter pw = response.getWriter();
pw.write("<SCRIPT TYPE='text/javascript'>" + msg + "</SCRIPT>");
pw.close();
}
|