decorators.xml内容如下<?xml version="1.0" encoding="UTF-8"?>
<decorators defaultdir="/pages/decorators">
<decorator name="default" page="default.jsp">
<pattern>/*</pattern>
</decorator>
<decorator name="noTab" page="noTabbedPage.jsp"/>
<excludes>
<pattern>*/tree.do*</pattern>
</excludes>
</decorators>代码部分
ServletOutputStream out = null;
try {
JSONObject json = new JSONObject();
//告知成功與否
json.put("executeSuccess", iExecuteSuccess);
response.setHeader("Content-Type", "text/plain;charset=UTF-8");
out = response.getOutputStream();
out.write(json.toString().getBytes("UTF-8"));
out.flush();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if(out != null){
out.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
return null;用Ajax更新分数的,更新后不希望页面跳转,直接用outputstream发送一段JSon提示信息到页面,可是每次response都被截获后变成了sitemesh自己包装过的response,然后会跳转,上面代码里面按道理说是不会跳转的,可页面还是跳转了,请问是怎么回事啊,难道是sitemesh的问题?
<decorators defaultdir="/pages/decorators">
<decorator name="default" page="default.jsp">
<pattern>/*</pattern>
</decorator>
<decorator name="noTab" page="noTabbedPage.jsp"/>
<excludes>
<pattern>*/tree.do*</pattern>
</excludes>
</decorators>代码部分
ServletOutputStream out = null;
try {
JSONObject json = new JSONObject();
//告知成功與否
json.put("executeSuccess", iExecuteSuccess);
response.setHeader("Content-Type", "text/plain;charset=UTF-8");
out = response.getOutputStream();
out.write(json.toString().getBytes("UTF-8"));
out.flush();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if(out != null){
out.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
return null;用Ajax更新分数的,更新后不希望页面跳转,直接用outputstream发送一段JSon提示信息到页面,可是每次response都被截获后变成了sitemesh自己包装过的response,然后会跳转,上面代码里面按道理说是不会跳转的,可页面还是跳转了,请问是怎么回事啊,难道是sitemesh的问题?
解决方案 »
- jsp页面二次取值问题
- ssh action请求后 页面分割思路的问题
- 关于synchronized的问题
- javamial
- 下拉列表的二级联动
- 一个关于无状态sessionbean的怪问题?
- struts的连接池中得到的Connection对象,使用完毕后是否要关闭close()
- 关于hibernate的表关联问题
- eclipse2.13+lomboz+tomcat5.0.27+easy struts不能debug jsp
- 在使用.war的时候,servlet里面使用getRealPath的问题
- 加载自己做的spring新接口时报的异常,大家帮忙看下这是什么异常?怎么解决?
- 找了不少高手都解决不了的问题,请大家帮忙,谢谢!
response.setHeader("Content-Type", "text/plain;charset=UTF-8"); ---》text/plain LZ要返回TXT??
json的url配一下,然后在decorators.xml屏蔽掉
举例:
json url:var url = "../ajaxValid/ajaxTest.action";
decorators.xml配置:
<pattern>/ajaxValid/ajaxTest.action</pattern>