0

HI in my web development i'm finding a strange issue, i'm having an entire table as input field where users enter data and send back to Spring Rest, i'm getting the data as String and parsing it using Gson library

$http({
	    method: 'POST',
	    url: 'saveTableData.do',
	    headers: { 'Content-Type': 'application/json;'},
	    data:'tableVal'+data1
	}) ;

and my Spring controller looks like

@RequestMapping(value="/saveTableData",method=RequestMethod.POST)
public void saveTableDataToDb(@RequestBody String tableData) {

    Gson gson = new Gson();
    TableData dataFromJson = gson.fromJson(tableData, TableData.class);
}    

the issue is data is being sent to backend but in console i'm getting Failed to load resource: the server responded with a status of 404 (Not Found)

Why is this and will it impact in future

5
  • try changing url to /SaveTableData Commented Dec 30, 2015 at 6:13
  • should be /saveTableData, being lower case 's'? Commented Dec 30, 2015 at 6:23
  • @entre nope! no use any other solutions Commented Dec 30, 2015 at 7:09
  • where is your spring response for the http call Commented Dec 30, 2015 at 8:19
  • was using @resposeody for long time totally forgot this return new ResponseEntity(HttpStatus.OK) Commented Dec 30, 2015 at 9:28

1 Answer 1

1

I'm not really a Spring user, but my bet would be that the 404 comes from you not returning anything back from your method.

In dummy code I would expect something like this:

public Response saveTableDataToDb(MyVar myvar) {
    // Do some smart business logic
    Response resp = new Response();
    resp.setResultCode(200) //http for everything ok, or whatever you need
    return resp;
}

Like I said I don't really know Spring but that would be my bet since you have a void method at the moment.

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.