有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java HTTP 404源服务器找不到目标资源的当前表示形式,或者不愿意透露存在该表示形式。不起作用

我正试图创建一个虚拟的Restful Web服务,但出于某种原因,我一直犯这个错误: HTTP状态404-未找到 类型状态报告消息找不到描述源服务器找不到目标资源的当前表示形式,或者不愿意透露存在该表示形式

我已导入所有jersey文件以使用rest,这是我的web。xml代码:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://java.sun.com/xml/ns/javaee" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 
version="3.0">
  <display-name>YEs</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>

 <servlet>
    <servlet-name>JAVA WS</servlet-name>
    <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>

<init-param>
    <param-name>jersey.config.server.provider.packages</param-name>
    <param-value>trying</param-value>
</init-param>

<load-on-startup>1</load-on-startup>

</servlet>

<servlet-mapping>

    <servlet-name>JAVA WS</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

</web-app>

这是我的班级:

package trying;

import javax.ws.rs.core.MediaType;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;


 @Path("/Try")
 public class wallaimtrying {

    @GET
    @Produces(MediaType.TEXT_XML)
    public String sayHello() {
        
        String response = "<?xml version = '1.0'>" + "<hello> Hello XML </hello>";
        return response;
    }
    
    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public String sayHelloJSON() {
        
        String response = null;
        return response;
    }
}

我的服务器使用端口8082,但由于某些原因,当我尝试localhost:8082/YEs/try时

我得到了404错误


共 (0) 个答案