2013年10月30日星期三

jetty as an embedded server error

/ * Purpose: Experimental procedures embedded jetty
Results:
* /
public class TestJetty {
public static void main (String [] args) {
Server server = new Server ();
QueuedThreadPool threadPool = new QueuedThreadPool (200);
server.setThreadPool (threadPool);

Connector connector = new SelectChannelConnector ();
connector.setPort (8080);
server.addConnector (connector);

WebAppContext webapp = new WebAppContext ();
webapp.setContextPath ("/");
webapp.setWar ("E :/ jetty/jetty-6.1.26/jetty-6.1.26/webapps/TestJetty.war");
webapp.setClassLoader (Thread.currentThread (). getContextClassLoader ());
server.setHandler (webapp);
try {
server.start ();
server.join ();
} catch (Exception e) {
e.printStackTrace ();
}

}
}

run as application startup , http://localhost:8080/TestJetty/index.jsp error 404 ,
But I E :/ jetty/jetty-6.1.26/jetty-6.1.26/webapps/TestJetty.war Here is the jar , and this project is the jsp below , we help facie < br> ------ Solution ----------------------------------------- ---
looking at your code , you are to go to the root of the application for registration of the bar .
------ For reference only -------------------------------------- -
What do you mean , webapp.setContextPath ("/"); phrase is not to say the path to access it , I do not understand , seek advice
------ For reference only - --------------------------------------
try to access this path : http:/ / localhost: 8080/index.jsp
------ For reference only ------------------------------ ---------
is indeed the case , thank you, I think this webcontext there are other attributes , help me to explain it, or that you have this API , I have not found
webapp.setContextPath ("/");
webapp.setDescriptor ("WebContent / WEB-INF / web.xml");
webapp.setResourceBase ("WebContent");
------ For reference only ---------- -----------------------------
lacks a good way , the official website to see the API documentation and forums , Chinese data little .

webapp.setContextPath ("/");
set access paths, such as can be set : / myapp

webapp.setDescriptor ("WebContent / WEB-INF / web.xml");
set web.xml location , generally do not need to use

webapp.setResourceBase ("WebContent");
set up a Web application's root directory , if you are not packaged into a war to publish , but directly provides a directory ( JSP what benefits can be modified at any time )

没有评论:

发表评论