Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Web服务在Tomcat和Eclipse上未正确执行_Eclipse_Web Services_Tomcat7_Restful Url - Fatal编程技术网

Web服务在Tomcat和Eclipse上未正确执行

Web服务在Tomcat和Eclipse上未正确执行,eclipse,web-services,tomcat7,restful-url,Eclipse,Web Services,Tomcat7,Restful Url,我正在尝试创建一个Web服务,它将温度从C转换为F。我遵循了一个基本教程,即: 我遵循了帖子建议的相同步骤,并使用apachetomcatv7运行该项目。但是,输出并不像教程所说的那样显示。当我运行我的项目时,我得到一个错误,上面写着httpstatus 404-/RestJerseyExample/;资源不可用。我是新来的,我不知道我会错在哪里。我正在使用Windows7。非常感谢您的建议 这是我的web.xml: <?xml version="1.0" encoding="UTF-8"

我正在尝试创建一个
Web服务
,它将温度从
C
转换为
F
。我遵循了一个基本教程,即: 我遵循了帖子建议的相同步骤,并使用
apachetomcatv7
运行该项目。但是,输出并不像教程所说的那样显示。当我运行我的项目时,我得到一个错误,上面写着
httpstatus 404-/RestJerseyExample/;资源不可用
。我是新来的,我不知道我会错在哪里。我正在使用
Windows7
。非常感谢您的建议

这是我的
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_3_0.xsd"
version="3.0">
<display-name>CrunchifyRESTJerseyExample</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>Jersey Web Application</servlet-name>
    <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Jersey Web Application</servlet-name>
    <url-pattern>/crunchify/*</url-pattern>
</servlet-mapping>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>RESTJerseyExample</groupId>
<artifactId>RESTJerseyExample</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
    <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
        <source>1.8</source>
        <target>1.8</target>
        </configuration>
    </plugin>
    <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.4</version>
        <configuration>
        <warSourceDirectory>WebContent</warSourceDirectory>
        <failOnMissingWebXml>false</failOnMissingWebXml>
        </configuration>
    </plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>asm</groupId>
        <artifactId>asm</artifactId>
        <version>3.3.1</version>
    </dependency>
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-bundle</artifactId>
        <version>1.19</version>
    </dependency>
    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20140107</version>
    </dependency>
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-server</artifactId>
        <version>1.19</version>
    </dependency>
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-core</artifactId>
        <version>1.19</version>
    </dependency>
</dependencies>
</project>

你没有注册你的资源。您应该在
web.xml
中添加
配置:


Jersey Web应用程序
com.sun.jersey.spi.container.servlet.ServletContainer
com.sun.jersey.config.property.packages
com.crunchify.restjersey
1.
然后尝试以下URL:
http://localhost:8080/crunchify/

请提供配置和资源文件,如web.xml请检查我的编辑您是否试图通过“/RestJerseyExample/”上下文访问服务器?我认为应该是“/CrunchifyRESTJerseyExample/crunchify/{your_resource_context}”,教程提到了第一个。但是,我的类名是第二个。刚刚尝试了你的建议,我仍然收到错误404。你想联系什么资源?