HTTP状态404时,使用Jersey在Java中运行简单的RESTful Web服务 [英] HTTP Status 404 when running simple RESTful web service in Java using Jersey
问题描述
当使用Jersey在Java中运行简单的RESTful Web服务时,我正在获得 HTTP状态404
。我正在使用教程
我所犯的错误是不指定服务名称(由 @Path
注释指定)。做完之后就行了。
所以本质上,点击的URL应该是 http:// localhost:8080 / com.kj.rest.jersey.first / rest / path_from_rest_class ,之前我错过了 path_from_rest_class
。
I am getting HTTP Status 404
when running simple RESTful web service in Java using Jersey. I am following the tutorial REST with Java (JAX-RS) using Jersey. I have copied all the jars that I downloaded from Jersey download site to WEB-INF/lib folder of my project(please see the screenshot for jars).
When I run the application from eclipse development environment Eclipse Console shows that Tomcat was started successfully. My web-app is deployed and I can see index.html coming up. But hitting http://localhost:8080/com.kj.rest.jersey.first/ gives Http Status 404.
My Environment:
- Spring Tool Suite as my eclipse dev environment
- Jersey 2.22.2 jars
- Apache Tomcat v8.0
Please note I am not using Maven in my project and I also looked at other similar questions here but none of them solved my issue.
What am I missing, where should I look for the issue, which logs?
The mistake that I was making was to not specify the service name(specified by @Path
annotation) in the URL. After doing that it worked.
So essentially the URL to hit should be http://localhost:8080/com.kj.rest.jersey.first/rest/path_from_rest_class and I missed the path_from_rest_class
earlier.
这篇关于HTTP状态404时,使用Jersey在Java中运行简单的RESTful Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!