问题描述
- Pushlet: bad request
- 页面展示如图所示,连续不停的点击【注册】按钮,点击【注册】按钮时调用reg()函数,关于reg()函数见下面的源码
页面报如下错误:
后台报如下错误:
Pushlet[WARN] Pushlet: bad request no id specified event=refresh
请高手帮忙解决下,谢谢,源代码如下所示:
后台代码java代码:
public class HelloWorldEventPullSource implements Serializable {/** * 序号 */private static final long serialVersionUID = 4888020190322182632L;static public class HelloWorldEvent extends EventPullSource{ @Override protected long getSleepTime() { return 5000; } @Override protected Event pullEvent() { try { Thread.sleep(1000 * 5); } catch (InterruptedException e) { e.printStackTrace(); } Event event =Event.createDataEvent(""/source/event"");//事件标识 event.setField(""msg""helloworld"");//封装参数 return event; }}
}
页面代码如下所示:
<%@ page language=""java"" contentType=""text/html; charset=utf-8""
pageEncoding=""utf-8""%>
<!DOCTYPE html PUBLIC ""-//W3C//DTD HTML 4.01 Transitional//EN"" ""http://www.w3.org/TR/html4/loose.dtd""><script type=""text/javascript""> PL._init(); function reg() { PL.joinListen('/source/event'); //事件标识 在数据源中引用 } function onData(event) { console.log(event.get(""msg"")); } </script>
解决方案
有可能是你的参数不符合后台的约定,和后台人员联调一下
时间: 2024-10-03 16:47:01