1

我有一个使用 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();

它工作正常....

为什么我不能对黑板 Buildingblock 进行 POST?

4

1 回答 1

0

默认情况下,Blackboard Learn 会阻止外部帖子。

您需要在@NoXSRF上方添加注释@RequestMapping,这应该允许您访问它。

于 2015-04-04T15:12:43.520 回答