HttpHandler无法处理http请求

时间:2016-06-25 19:48:54

标签: java server httphandler httpserver

我正在尝试使用com.sun.net.httpServer。*库构建https代理服务器。 当我按如下方式定义服务器上下文时:

httpServer.createContext("/test", new MyHandler());

我从浏览器打开url:“https://localhost:443/test”它按预期工作,但是当服务器上下文以这种方式定义时:

httpServer.createContext("/", new MyHandler());

我注意到在输入以下网址时我的处理程序未被使用:“https://www.google.co.il/

我错过了什么?

1 个答案:

答案 0 :(得分:0)

此行只会更改上下文路径,而不会更改服务器URL。

httpServer.createContext("/", new MyHandler());

因此,对于此上下文,您将通过此网址获得回复 - " https://localhost:443/"。

相关问题