我在 Java 运行时使用通道 API。我映射到 /_ah/channel/connected 的 servlet 似乎没有运行。我正在创建一个通道,传递令牌,然后在服务器上打开它。这工作正常。我确实在我的日志中看到了对 /_ah/channel/connected 的调用,但是没有出现日志消息并且代码似乎没有运行。下面是我的代码和 web.xml
ChannelConnectedServlet.java:
public class ChannelConnectedServlet extends HttpServlet{
private static final Logger logger = Logger.getLogger(ChannelConnectedServlet.class
.getName());
private void process(HttpServletRequest req, HttpServletResponse resp) throws IOException {
logger.log(Level.WARNING,"test");
//do stuff here
}
public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws IOException, ServletException {
logger.log(Level.WARNING,"Channel connected!");
process(req, resp);
}
}
网页.xml:
<servlet-mapping>
<servlet-name>ChannelConnected</servlet-name>
<url-pattern>/_ah/channel/connected</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>ChannelConnected</servlet-name>
<servlet-class>com.myapp.server.channel.ChannelConnectedServlet</servlet-class>
</servlet>
断开连接请求也会发生相同的行为。帮助!!!