使用 REST 插件对 Struts2 的 POST 请求未收到响应 [英] POST request to Struts2 with REST plugin not receiving response

查看:22
本文介绍了使用 REST 插件对 Struts2 的 POST 请求未收到响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 struts2-rest-plugin v.2.2.3 的 struts2 应用程序.

I have a struts2 application which uses the struts2-rest-plugin v.2.2.3.

在将请求路由到操作及其方法方面,一切都很好,我还使用 ModelDriven 来指定在使用 JSON 和 XML 等扩展时要序列化的对象.

Everything is working great when it comes to the routing of the requests to the actions and its methods and I'm also using ModelDriven to specify the object to serialise when using extensions like JSON and XML.

我遇到的问题是,当我向 struts 层发送 POST 或 PUT 请求时,我只得到一个空响应.

The problem I'm having is that when I send a POST or PUT request to the struts layer I just get an empty response.

我正在向操作发送一个 POST 请求,如下所示:http://localhost:8080/alert-settings!update.json.我在该方法中有一个断点,它被调用并且代码运行并完成.我有一种感觉,问题可能是我正在尝试使用 ModelDriven 接口向我发送响应,并且由于某种原因,rest-plugin 不喜欢这样,但我不知道它为什么会这样.

I am sending a POST request to the action like so: http://localhost:8080/alert-settings!update.json. I have a breakpoint in that method and it gets called and the code runs and completes. I have a feeling the issue might be that I am trying to use the ModelDriven interface to send me back the response and for some reason the rest-plugin doesn't like this but I don't know why it would behave like that.

在使用 REST 插件时接收来自 POST 请求的响应是否存在已知问题?我到处都找遍了,真的找不到任何东西.

Is there a known issue with receiving responses from POST requests while using the rest plugin? I have looked everywhere and can't find anything about it really.

感谢任何帮助,我可以根据要求提供更多详细信息.

Any help appreciated and I can provide any more details on request.

推荐答案

我遇到了同样的问题.有没有试过在struts.xml文件中设置:

I encountered the same issue. Have you tried to set in the struts.xml file:

struts.rest.content.restrictToGET = false

查看其余插件文档上的最后一个设置

这篇关于使用 REST 插件对 Struts2 的 POST 请求未收到响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆