ssh + dwr 问题

来源:互联网 发布:小黑屋写作软件mac 编辑:程序博客网 时间:2024/05/21 22:51

在SSH+DWR项目中。

进入DWR测试页面

http://localhost:8080/crm/dwr

 

测试一个只返回参数内容的方法,并在控制台输出。

控制台输出正常,用TCP/IP Monitor监视数据也正常

但就是在测试页上没有返回值响应。

 

最后终于在过滤器中找到原因。

 

esponse.setContentType("text/html;chartset="+charSet);

 

是ContentType属性影响了客户端的响应。

 

在这种情况下,要么不管它,要么就正确设置。

 

总结如下:

 

1.

服务端 向 客户端 发送 JSON数据 时:
Content-Type = 'application/json;charset=UTF-8'


2.
服务端 向 客户端 发送 JS 代码 时:
Content-Type = 'text/javascript;charset=UTF-8'

3
服务端 判断 客户端 提交的是否是 JSON数据 时 :

Content-Type = 'application/json;charset=UTF-8'
Content-Type = 'text/json;charset=UTF-8'
Content-Type = 'text/javascript;charset=UTF-8'
Content-Type = 'application/javascript;charset=UTF-8'