⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.java

📁 jetty SERVER連接資料庫用的軟體
💻 JAVA
字号:
//========================================================================//Copyright 2006 Mort Bay Consulting Pty. Ltd.//------------------------------------------------------------------------//Licensed under the Apache License, Version 2.0 (the "License");//you may not use this file except in compliance with the License.//You may obtain a copy of the License at //http://www.apache.org/licenses/LICENSE-2.0//Unless required by applicable law or agreed to in writing, software//distributed under the License is distributed on an "AS IS" BASIS,//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.//See the License for the specific language governing permissions and//limitations under the License.//========================================================================package org.mortbay.jetty;import org.mortbay.jetty.bio.SocketConnector;import org.mortbay.jetty.handler.ContextHandler;import org.mortbay.jetty.handler.ContextHandlerCollection;import org.mortbay.jetty.servlet.ServletHandler;import org.mortbay.jetty.webapp.WebAppContext;import org.mortbay.log.Log;import org.mortbay.util.URIUtil;public class Main{    /* ------------------------------------------------------------ */    /* ------------------------------------------------------------ */    /** Construct server from command line arguments.     * @param args      */    public static void main(String[] args)    {        if (args.length<1 || args.length>3)        {            System.err.println("Usage - java org.mortbay.jetty.Main [<addr>:]<port>");            System.err.println("Usage - java org.mortbay.jetty.Main [<addr>:]<port> docroot");            System.err.println("Usage - java org.mortbay.jetty.Main [<addr>:]<port> -webapp myapp.war");            System.err.println("Usage - java org.mortbay.jetty.Main [<addr>:]<port> -webapps webapps");            System.err.println("Usage - java -jar jetty-x.x.x-standalone.jar [<addr>:]<port>");            System.err.println("Usage - java -jar jetty-x.x.x-standalone.jar [<addr>:]<port> docroot");            System.err.println("Usage - java -jar jetty-x.x.x-standalone.jar [<addr>:]<port> -webapp myapp.war");            System.err.println("Usage - java -jar jetty-x.x.x-standalone.jar [<addr>:]<port> -webapps webapps");            System.exit(1);        }                try{                        // Create the server            Server server = new Server();            ContextHandlerCollection contexts = new ContextHandlerCollection();            server.setHandler(contexts);                        SocketConnector connector = new SocketConnector();            String address = args[0];            int colon = address.lastIndexOf(':');            if (colon<0)                connector.setPort(Integer.parseInt(address));            else            {                connector.setHost(address.substring(0,colon));                connector.setPort(Integer.parseInt(address.substring(colon+1)));            }            server.setConnectors(new Connector[]{connector});                        if (args.length<3)            {                ContextHandler context = new ContextHandler();                context.setContextPath(URIUtil.SLASH);                context.setResourceBase(args.length==1?".":args[1]);                ServletHandler servlet = new ServletHandler();                servlet.addServletWithMapping("org.mortbay.jetty.servlet.DefaultServlet", URIUtil.SLASH);                context.setHandler(servlet);                contexts.addHandler(context);            }            else if ("-webapps".equals(args[1]))            {                WebAppContext.addWebApplications(server, args[2], WebAppContext.WEB_DEFAULTS_XML, true, true);            }            else if ("-webapp".equals(args[1]))            {                WebAppContext webapp = new WebAppContext();                webapp.setResourceBase(args[2]);                webapp.setContextPath(URIUtil.SLASH);                contexts.addHandler(webapp);                            }                            server.start();                    }        catch (Exception e)        {            Log.warn(Log.EXCEPTION,e);        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -