我正在使用 restful webservices 我有一个简单的代码,如下所示:
@Path("/v1/status")
public class ControllerServices
{
@GET
@Produces(MediaType.TEXT_HTML)
String printOnly()
{
System.out.println("running successfully");
return "<p>this webservice</p>";
}
}
我的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>com.techbloomer.services</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>
当我要求
http://localhost:8080/webservicesForIndTadka/rest/v1/status
它给出的错误为
HTTP Status 405 - Method Not Allowed
type: Status report
message: Method Not Allowed
description: The specified HTTP method is not allowed for the requested resource.