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