【发布时间】:2016-04-04 12:19:47
【问题描述】:
我在 Spring Controller Class 中为 rest web service 编写了这段代码。构建项目后,我尝试使用 service 使用 Restful-Client
RestService 代码:-
@RequestMapping(value="/someurl/{prm_passPhraseCode}/{prm_email}", method= RequestMethod.POST)
public @ResponseBody User sendResetLink(@PathVariable("prm_passPhraseCode") String prm_sPassPhrase, @PathVariable("prm_email") String prm_sEmail , HttpServletRequest prm_ObjRequest, HttpServletResponse prm_ObjResponse){
......
..... //some more logical Code.
return new User(); //just dummy object for reference.
}
这里是我尝试访问 URL 的方式。我选择了方法类型为post。
我还添加了两个标题
Content-Type : application/jsonAccept : application/json
网址http://127.0.0.1:8080/webservice.staff.backend/someurl/23812397997713/kumarvikrant625@gmail.com
尽管我的所有其他 Rest 服务 url 无论是 GET 还是 POST 都可以正常工作。
我也尝试更改method = RequestMethod.GET,但仍然出现相同的错误。
错误:-
Status Code 406 : The resource identified by this request is only capable of
generating responses with characteristics not acceptable according to the request "accept" headers.
如果有人有想法请帮忙。
【问题讨论】:
-
似乎 sendResetPasswordLink 没有反映在请求映射中
-
不反映是什么意思??实际上没有得到你..@Benchik
-
喜欢@RequestMapping(value="/someurl/sendResetPasswordLink/{prm_passPhraseCode}/{prm_email}"
标签: java json spring web-services rest