【发布时间】:2014-10-04 21:54:25
【问题描述】:
我来了
错误 405:方法不允许
MessageEnd.java:
package com.example.wordcount;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
@Path("/jersey")
public class MessageEnd {
@GET
@Path("/getvalue/{word}")
@Produces(MediaType.TEXT_PLAIN)
public Response sayHello(@PathParam("word") String word){
String output = " Count of word " + word;
return Response.status(200).entity(output).build();
}
@PUT
@Path("/sendvalue/{msg}")
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
public Response sendMsg(@PathParam("msg") String msg){
String output = "Received message= " + msg;
return Response.status(200).entity(output).build();
}
}
仅供参考,@GET 工作正常。
我正在使用以下 URI:
http://localhost:8080/message/jersey/sendvalue/hi
【问题讨论】:
-
PUT 做得怎么样?显示您的客户代码(如果有)
-
我没有任何客户端代码,我通过 URI 发送参数。 (如果我做错了什么请纠正我)
标签: java http tomcat jersey put