I have the following call in my JavaScript:
new Ajax.Request('/orders/check_first_last/A15Z2W2',
{asynchronous:true, evalScripts:true,
parameters:{first:$('input_initial').value,
last:$('input_final').value,
order_quantity:$('input_quantity').value}});
What do I need to do to get Spring MVC (3.0) to handle this?
A few notes:
@PathVariablegets a variable defined with{..}in the request mapping@RequestParamis equvallent torequest.getParameter(..). When no value is specified, the name of the parameter is assumed (first,last). Otherwise, the value (order_quantity)is obtained from the request.@ResponseBodymeans you need Jackson or JAXB present on the classpath, and<mvc:annotation-driven>in the xml config. It will render the result with JSON or XML respectively.If you want to write HTML to the response directly, you have two options:
Stringand return the HTML as aStringvariableHttpServletResponse responseparameter to the method and use theresponse.getWriter().write(..)method to write to the responseResource: Spring MVC documentation