我写了jettyserver.java
作为启动服务,这是代码,
public class jettyserver {
public static void main(String[] args) throws Exception {
Server server = new Server(8080);
ServletHolder servletHolder = new ServletHolder(ServletContainer.class);
Map<String, String> parameterMap = new HashMap<String, String>();
parameterMap.put("jersey.config.server.provider.packages", "com.heu.cs.mavenproject3");
servletHolder.setInitParameters(parameterMap);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/jettyproject/*");
context.addServlet(servletHolder, "/*");
server.setHandler(context);
server.start();
server.join();
}
}
我写了demo.java
作为测试演示,
@Path("/demo")
public class demo {
@GET
@Produces({"text/html"})
public String index(){
return "OK";
}
}
然后我运行jettyserver.java
,我就好了
this
我们可以看到,那是对的
但是我在浏览器中输入localhost:8080 / jettyproject / index.html或localhost:8080 / index.html,我收到了404错误404 Error
我该怎么办?什么错误的代码????