My Javascript code:
function singleCopySave() { var sam1="00:A0:C9:14:C8:29"; var mac=toLrad.split(":").map(Integer.parseInt(_,16)).foldLeft(0L) {case (acc,item) => acc*256+item}; var JSONObject = {}; JSONObject["toLrad"]=sam1; var jsonData=dojo.toJson(JSONObject); dojo.xhrPost({ url :"/unified/singleCopy", preventCache:true, handleAs: "text", postData:jsonData, headers: {"Content-Type": "application/json"}, sync:true, load: function(response, ioArgs) { retVal = response; }, error: function(errorResponse, ioArgs) { } }); } My Java REST code looks like below:
@POST @Path("/singleCopy") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.TEXT_PLAIN) public String singleApCopy(sampleDTO dto,@Context HttpServletRequest request, @Context HttpServletResponse response) { long toLradId = dto.getToLrad(); return "success"; It is not hitting the REST url. There's a mistake in converting the string value to long. Could someone please help me out the syntax problem in converting to long? Or is there a way to convert the mac address in the DTO.java ?
v- which isn't hex