-
Feb 7th, 2011, 08:15 PM
#1
Roo 1.1.1 JSON
I am using ROO 1.1.1 and I am trying to add JSON support using the JSON all command. This worked for the most part and with a get call using Accept=application/json I am able to get to the method in the controller successfully. I get an error though on the response saying it can't resolve the view. Do the need to content based view resolver? I did not think that was the case with Roo 1.1.1. I am not sure what I am missing. Any help would be appreciated.
This is the error I see
Could not resolve view with name '[]' in servlet.
-
Feb 8th, 2011, 03:29 PM
#2
I believe this is related to how you send JSON document to the controller. The Roo documentation contains a section about the JSON integration which also shows the relevant CURL commands. Please use a traffic monitoring tool such as firebug to review if your JSON documents are correct.
http://static.springsource.org/sprin...html#base-json
-
Feb 8th, 2011, 03:39 PM
#3
I am using what Roo generated without making any changes after running the json all command. So the JSON is just being sent from the generated JSON method in the controller which is in turn using the JSON serialization method generated on the underlying entity. It looks like the generated method on the controller is firing ok, but then an error occurs because a view cannot be found to handle the response. Since this was all generated by roo 1.1.1 I am not sure what I am missing or need to add manually to get it to work. I am using Firebug and running the app in debug mode so I can see the controller method being invoked properly. Thanks.
-
Feb 8th, 2011, 04:11 PM
#4
I am not exactly sure what you expect here. If you do a curl request, do you receive a JSON document? If so, you need to send the same request from your view artifact and process the result accordingly.
It is up to you to write the processing code for JSON response in the view. Roo generates the controllers which accept and deliver JSON, it is up to you to integrate with that.
-
Feb 8th, 2011, 04:42 PM
#5
Sorry for the confusion. I do not receive a JSON document back. I get a server error. I have written the client side code to invoke the view (which is working fine) and process the response (which is not because the response is not getting back). The controller method is being invoked successfully from my client page (I can see it on the server), but the response is never coming back to the client (CURL or otherwise) because following the controller method invocation on the server it is failing when going through the Spring view resolver because it cannot find a view to resolve to so it can send back the response. My question is do I need to manually add a view resolver in Spring config to handle this so the response is sent back correctly to my client? I thought roo handled this automatically, but I was unsure. Thanks for your help.
-
Feb 8th, 2011, 04:48 PM
#6
Ok, we are getting a bit closer now
.
If the controller does not return a JSON document then the request is not correct. most likely your request does not send the appropriate accept headers (the GET request needs to have the "Accept: application/json") header (please review this with firebug). The correctness of the URL might be another problem.
There is no need to register a special view resolver. The returned document is expected because all exceptions are rendered as html (as defined in webmvc-config.xml).
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules