我有一个使用Spring MVC的构建块。
控制器如下所示:
@RequestMapping(value = "/addUpdateUser",method = {RequestMethod.GET, RequestMethod.POST})
@ResponseBody
public String getAddUpdateUser(HttpServletRequest request) {
String xml = request.getParameter("xml");
....
当我从我的应用程序中这样调用时:
URI url = new URI(baseUrl+"/users/addUpdateUser");
HttpClient httpclient = HttpClients.createDefault();
HttpPost httppost = new HttpPost(url);
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
它失败了...我得到一个网页,说我无法访问此页面,但是如果我将代码更改为像这样的HttpGet:
URI url = new URI(baseUrl+"/users/addUpdateUser");
HttpClient httpclient = HttpClients.createDefault();
HttpGet httpget = new HttpGet(url);
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
工作正常......
为什么我不能对黑板Building Block进行POST?
答案 0 :(得分:0)
Blackboard Learn默认阻止外部帖子。
您需要在@NoXSRF
上方添加@RequestMapping
注释,以便您可以访问它。