-2
這是我的網址; http://localhost:2222/test1/test1/home/helloRestful Jetty HTTP錯誤404訪問未找到
此網址導致下面的錯誤。 HTTP錯誤404 訪問/ test1/test1/home/hello問題。原因: 未找到下面
ResourceConfig config = new ResourceConfig();
config.packages("java"); // this is where my main class and resource resides
ServletHolder servlet = new ServletHolder(new ServletContainer(config));
Server server = new Server(2222);
ServletContextHandler context = new ServletContextHandler(server, "/test1",ServletContextHandler.NO_SESSIONS);
context.addServlet(servlet,"/test1");
try
{
server.start();
server.join();
}
catch(Exception ex){
ex.printStackTrace();
server.destroy();
}
我的資源
@Path("/home")
public class Resources {
@GET
@Path("/hello")
@Produces(MediaType.TEXT_PLAIN)
public String helloWorld() {
return "Hello, world!";
}
}
我在做什麼錯誤
及主要的servlet起動器和資源類?
編輯:我認爲問題是在「包」部分,但我不知道如何配置它。 謝謝
讓我們繼續評論民事請。 –