Я просто создал проект и развернул его. Я попытался получить доступ к ресурсу, щелкнув текст «Ресурс Джерси» на снимке экрана ниже, но вместо этого получил код 404 (для URL-адреса: http://localhost:8080/messenger/webapi/myresource) ):

Вышеуказанный index.jsp:
Код: Выделить всё
Jersey RESTful Web Application!
[url=webapi/myresource]Jersey resource[/url]
Visit [url=http://jersey.java.net]Project Jersey website[/url]
for more information on Jersey!
Код: Выделить всё
package in.net.myproj.practice.javabrains;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
/**
* Root resource (exposed at "myresource" path)
*/
@Path("myresource")
public class MyResource {
/**
* Method handling HTTP GET requests. The returned object will be sent
* to the client as "text/plain" media type.
*
* @return String that will be returned as a text/plain response.
*/
@GET
@Produces(MediaType.TEXT_PLAIN)
public String getIt() {
return "Got it!";
}
}
Код: Выделить всё
Jersey Web Application
org.glassfish.jersey.servlet.ServletContainer
jersey.config.server.provider.packages
in.net.hrs.practice.javabrains
1
Jersey Web Application
/webapi/*
Код: Выделить всё
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
in.net.myproj.practice
messenger
war
1.0-SNAPSHOT
messenger
messenger
org.apache.maven.plugins
maven-compiler-plugin
3.11.0
true
17
17
org.apache.maven.plugins
maven-war-plugin
3.4.0
org.glassfish.jersey
jersey-bom
${jersey.version}
pom
import
org.glassfish.jersey.containers
jersey-container-servlet-core
org.glassfish.jersey.inject
jersey-hk2
4.0.0-M1
UTF-8
3.4.0
Подробнее здесь: https://stackoverflow.com/questions/793 ... g-resource
Мобильная версия