【发布时间】:2018-07-04 11:42:42
【问题描述】:
在执行此程序时,我收到 HTTP 状态 404 异常:
HTTP 状态 404 - /Restful_WebServices_Tuts/test/home
输入状态报告
消息 /Restful_WebServices_Tuts/test/home
描述 请求的资源不可用。
Apache Tomcat/8.0.36
这是我的应用类
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
@ApplicationPath("/test")
public class JAX_RS_Starter extends Application{
}
这是我使用 GET 注释的 Hello World 类
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.MediaType;
import java.lang.String;
@Path("/hello")
public class HelloRS{
@GET
@Produces("text/plain")
public String HelloWorld(){
return "Hello World";
}
}
还有我的 Web.xml 文件
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
<display-name>Restful WebServices Tuts</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
我该如何解决这个问题?
【问题讨论】:
-
/home你在哪里声明的? -
对不起,你好..我提到了家..但即使现在我也尝试过你好......同样的错误正在发生
标签: java rest web-services tomcat