无法POST到黑板构建块

时间:2015-02-06 16:52:33

标签: java spring-mvc blackboard

我有一个使用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?

1 个答案:

答案 0 :(得分:0)

Blackboard Learn默认阻止外部帖子。

您需要在@NoXSRF上方添加@RequestMapping注释,以便您可以访问它。