有人可以帮我吗,我不知道为什么,但是我的猜测全是关于路由配置的,所以当我尝试使用邮递员发送get请求时,找不到404
我的网址请求是:
http://localhost:8080/javaAPI/rest/secured/mesage
这是我的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" id="WebApp_ID" version="3.1">
<display-name>javaAPI</display-name>
<servlet>
<servlet-name>JAVA API</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer.class</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>test</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>JAVA API</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
这是我的课程
package test;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Path("/secured")
public class SecuredResource {
@GET
@Path("message")
@Produces(MediaType.TEXT_PLAIN)
public String securedMethod() {
return "This API is secured";
}
}