0

Jquery code to call my spring controller:

$.postJSON("/DialogController", myJSON, function(data) {
  previewDialog.html(data);
  previewDialog.dialog('open');
});

And then my controller code, which causes a http 500 error, I have debugged it and find it all works fine until the return string(view name), what am I doing wrong ?

@RequestMapping(value = "/DialogController", method = RequestMethod.POST)
public String dialogController(Model model, @RequestBody MyClass myClass) {
  myClass.setTitle("SUCCESS");       
  model.addAttribute("myClass", myClass);
  return "dialogContent";
}

Using jquery load with get request on the controller works to an extent - in that it returns the view and loads into dialog; but the attribute is not added to model and I can not post json data to the controller.

Any tips ?

2
  • What do your logs say? If you get a 500 error, you'll get a useful bunch of log entries telling you what you did wrong. Without seeing that, noone else can help you. Commented Aug 11, 2011 at 12:34
  • @skaffman that implies you think it should work ? The logs have nothing useful in them, just that the request has been made. I have stepped through the controller using a debugger and it all works except for the final return string. This is the normal method for returning a view - I have set up to use interalviewresolver and prefix/append the correct filename. Commented Aug 11, 2011 at 13:15

1 Answer 1

1

Have you tried putting @ResponseBody in your Controller? More information on this annotation is here: http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/mvc.html#mvc-ann-responsebody

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.