给配置文件添加返回内容:
<result name="hint" type="stream"> <param name="contentType">text/html</param> <param name="inputName">hint</param> </result>
在action中添加 参数:
private InputStream hint; public InputStream getHint() { return hint; } public void setHint(InputStream hint) { this.hint = hint; }
在action中添加一个方法:
private String transcoding(String str) { try { return new String(str.getBytes("utf-8"), "iso-8859-1"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return str; }
action需要执行的方法返回内容:
if(满足条件){ this.hint= new StringBufferInputStream (transcoding("1")); return "hint"; }
ajax:
success: function (result) { if (result == "1") { alert("成功返回action配置的内容"); return false; } }
时间: 2024-11-07 22:23:16