[英]Why do I get a 404 on this REST tutorial?
I've been following along on this REST tutorial here: http://www.vogella.com/tutorials/REST/article.html 我一直在这里关注此REST教程: http : //www.vogella.com/tutorials/REST/article.html
I've worked with REST before but not from the ground up and not using Tomcat, so I thought I'd start from the beginning and go from thee. 我以前使用过REST,但从未完全使用过,也没有使用过Tomcat,所以我认为我应该从头开始,从头开始。 Thing is I'm just getting a 404 when it comes to step 6.4 on this tutorial.
问题是,在本教程的第6.4步中,我只是得到404。
My web.xml looks like this: 我的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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>de.vogella.jersey.first</display-name>
<servlet>
<servlet-name>Jersey REST Service</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>de.vogella.jersey.first</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
And the resource seems to be getting detected by Tomcat upon startup: Tomcat在启动时似乎已检测到资源:
09/08/2014 9:35:47 AM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: .:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java
09/08/2014 9:35:47 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:RAGRest' did not find a matching property.
09/08/2014 9:35:47 AM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
09/08/2014 9:35:47 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 337 ms
09/08/2014 9:35:47 AM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
09/08/2014 9:35:47 AM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.41
09/08/2014 9:35:47 AM com.sun.jersey.api.core.PackagesResourceConfig init
INFO: Scanning for root resource and provider classes in the packages:
de.vogella.jersey.first
09/08/2014 9:35:47 AM com.sun.jersey.api.core.ScanningResourceConfig logClasses
INFO: Root resource classes found:
class de.vogella.jersey.first.Hello
09/08/2014 9:35:47 AM com.sun.jersey.api.core.ScanningResourceConfig init
INFO: No provider classes found.
09/08/2014 9:35:47 AM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.18 11/22/2013 01:21 AM'
09/08/2014 9:35:48 AM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
09/08/2014 9:35:48 AM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
09/08/2014 9:35:48 AM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/9 config=null
09/08/2014 9:35:48 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 956 ms
And tomcat is up and running at localhost:8080 as proved by visiting it in the browser. 并且tomcat已在localhost:8080上启动并运行,这已通过在浏览器中对其进行访问来证明。 Yet when I hit
http://localhost:8080/de.vogella.jersey.first/rest/hello
all I get is a 404. 但是当我点击
http://localhost:8080/de.vogella.jersey.first/rest/hello
我得到的只是一个404。
Am I missing something that is just blatantly obvious? 我是否遗漏了一些显而易见的东西? I must be...
我必须...
In case it matters, this is running tomcat 6 in Eclipse Helios on a MacBook Pro. 如果有问题,它将在MacBook Pro的Eclipse Helios中运行tomcat 6。
The URL part "de.vogella.jersey.first" needs to be the name of your WAR deployment unit (or web container specific methods like jboss-web.xml
or Tomcat context.xml
). URL部分“ de.vogella.jersey.first”必须是WAR部署单元的名称(或特定于Web容器的方法,如
jboss-web.xml
或Tomcat context.xml
)。
At least for normal web-apps this is the case, don't know why the tutorial speaks about the display-name. 至少对于普通的Web应用程序是这种情况,不知道本教程为什么讲显示名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.