Problem Description:
With spring Restful, you can correctly access the background through the URL of the browser's address bar and do not report errors, but the front desk always gets no data, the front desk also received a response from the background, that is, no data.
specific as follows:
using Spring Restful for different formats, you can send different formatted data, such as JSON, XML, HTML .....
For the configuration file, the following:
Refer to Spring MVC Rest learning one: http://my.oschina.net/heweipo/blog/337581
Reference Spring MVC Rest Learning II: http://my.oschina.net/heweipo/blog/340040
for the Controller interface, start with the following declaration:
@RequestMapping ("/getmessage") public String getMessage (httpservletrequest request, httpservletresponse response, Mod Elmap model) {model.put ("message", New Message ()); return null; }
request in Browser, Http:ip:port/server/uri/getmessage.json
The result: This method can be accessed, because I tried with a breakpoint, but the return value is empty, the original result should be to return a JSON-formatted message content, but not satisfactory. The specific reason is not very clear, but the following modifications have been made to solve the problem:
@RequestMapping ("/getmessage") public String getMessage (httpservletrequest request, Modelmap model) {Model.put (" Message ", new Message ()); return null; }
Summary:
Before and after the interface contrast, found that is more than a httpservletresponse response parameters, the results are passable, but the problem finally solved.
In addition I did not use @responsbody test, theoretically, should also be possible.
Spring MVC Rest return value is empty