Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/309.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java jetty外部地址_Java_Web_Jetty - Fatal编程技术网

Java jetty外部地址

Java jetty外部地址,java,web,jetty,Java,Web,Jetty,我希望我的服务器(jetty)可以通过网络在特定地址访问。 如何将jetty server配置为使用外部地址,例如:my_address_name.org或其他 因为默认情况下: server = new Server(port); WebAppContext context = new WebAppContext(); context.setResourceBase(app_path); context.setDescriptor(app_pa

我希望我的服务器(jetty)可以通过网络在特定地址访问。 如何将jetty server配置为使用外部地址,例如:my_address_name.org或其他

因为默认情况下:

server = new Server(port);
        WebAppContext context = new WebAppContext();

        context.setResourceBase(app_path);
        context.setDescriptor(app_path + "WEB-INF/web.xml");

        context.setConfigurations(new Configuration[] {
                new AnnotationConfiguration(), new WebXmlConfiguration(),
                new WebInfConfiguration(), new TagLibConfiguration(),
                new PlusConfiguration(), new MetaInfConfiguration(),
                new FragmentConfiguration(), new EnvConfiguration() });

        context.setContextPath(context_path);
        context.setParentLoaderPriority(true);
        server.setHandler(context);

        try {
            server.start();
            server.join(); ...

它在本地主机上运行…

此示例将绑定到特定IP并在端口9090上侦听:

Connector con = new SelectChannelConnector();
con.setHost("192.168.1.20");
con.setPort(9090);
server.addConnector(con);
(如果我记得很清楚的话,Jetty总是默认绑定到所有IP(0.0.0.0))