I am trying to send data though ajax message to spring controller. My ajax code
function postData(tag){
console.debug(tag);
var targetUrl = "/add/tag";
$.ajax({
url : targetUrl,
type : "POST",
data : tag,
dataType : "text",
success : function(response){
console.debug(response);
},
error : function(){
console.debug("error : ".concat(response));
}
});
}
and my controller code
@RequestMapping(value = "/add/tag", method = POST, consumes = { "application/json" },headers = "content-type=application/x-www-form-urlencoded")
@ResponseBody
public Integer addTag(HttpServletRequest request,
@PathVariable("uid") String gatheringUid, @RequestBody String tag) {
System.out.print(tag);
return gatheringService.updateGathering(gatheringUid, tags);
}
on the server side, it prints the value of the tag added by the "=" sign, while the value of the firebug column is displayed as I enterd.
For example, when I send test data, it prints “test” on the firebug console, and on the server side it prints “test =”.
Can someone tell me what the problem is?
Thanks in advance, Regards.
source
share