I am using a JQuery block to post data to a Spring controller, and here's the JQuery code
$('.usr').click(function () {
var user = $(this).text();
$.post("three.htm", {
user: user
},function(data){
console.log(JSON.stringify(data));
//window.location.replace('five.htm');
var form = $('<form action="five.htm" method="post">' +
'<input type="hidden" name="usrData" id="usrData" value="' + JSON.stringify(data) + '" />' +
'</form>');
$('body').append(form);
$("form").submit();
});
});
And the data from form is wanted in the spring controller whose code is as per below:
@RequestMapping(value="/home/five.htm")
public ModelAndView five(HttpServletRequest request,
HttpServletResponse response) throws Exception {
Map<String, String> model = new HashMap<String, String>();
String abc = request.getParameter("usrData");
return new ModelAndView("five",model);
}
The value of "abc" is found as only "{" whereas what I need is the stringifyed version of JSON data that was printed to console via the JQuery.