jetty作为嵌入式的服务器时报错
/*目的:实验程序中嵌入jetty
结果:
*/
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启动后,http://localhost:8080/TestJetty/index.jsp报错 404,
但是我E:/jetty/jetty-6.1.26/jetty-6.1.26/webapps/TestJetty.war下面是有这个jar的,并且这个项目下面是有这个jsp的,大家帮忙看下
------解决方案--------------------看你的代码,你是把应用给注册到根上去了吧。