本文介绍了带有tomcat的球衣给404错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用带有tomacat 6和Eclipse Juno的Jersey.
I am using Jersey with tomacat 6 and eclipse Juno.
我的文件名为HelloWorldService:
my file name is HelloWorldService :
package com.mkyong.rest;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;
@Path("/hello")
public class HelloWorldService {
@GET
@Path("/{param}")
public Response getMsg(@PathParam("param") String msg) {
String output = "Jersey say : " + msg;
return Response.status(200).entity(output).build();
}
}
Web.xml:
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Restful Web Application</display-name>
<servlet>
<servlet-name>jersey-serlvet</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>com.mkyong.rest</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jersey-serlvet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
当我使用Apache作为服务器运行我的项目时,它将转到此URL:
when i am running my project using Apache as server- it is going to this url:
http://localhost:8080/Test/WEB-INF/classes/com/mkyong/rest/HelloWorldService.java
我收到404错误.
我还尝试了version ="3.0",但没有成功.请帮帮我.
I also tried with version="3.0" and it didn't work.Please help me out.
推荐答案
您应按如下所示提供您的网址;
you should give your url as follows;
http://localhost:8080/<your-war-name>/rest/hello/<your-param>
这篇关于带有tomcat的球衣给404错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!