这是我的代码,我正在使用MyEclipse Juno和Apache Tomcat 7.0。和 我正在使用Jersey,我收到此错误“HTTP Status 500 - Servlet.init()for servlet Jersey REST Service引发了异常”。 我使用@ Path,@ GET和@Produces导入javax.ws.rs。,javax.ws.rs.core.MediaType,javax.servlet。。然后我离开了.. ??? : -
的index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML
4.01 Transitional//EN" "http://www.w3.org /TR/html4/loose.dtd">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>JAVA RESTful Demo</title>
</head>
<body>
JAVA RESTful Service
</body>
</html>
的readme.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><title>Read Me</title>
</head>
<body>
<h1>READ ME</h1>
</body>
</html>
的web.xml
<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>REST</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
v1_status.java
@Path("/v1/status")
public class v1_status {
@GET
@Produces(MediaType.TEXT_PLAIN)
public String returnTitle() throws ServletException{
return "<p>Java Web Servises</p>";
}}