I was trying a code which was a bit more complex and was testing things when everything I put into spring boot came out as null in the other end
Therefore I made the program simpler until I thought I knew it should work, but it still didn’t.
I am using springboot severeal places in my program, and it works there. Why doesn’t it work here?
@PostMapping("/Test")
public void Test(String number)
{
System.out.println("Number " + number);
}
$.post("/Test", "1")
This is what my console prints:
Number null
2
Answers
Assuming this will be your java code.
you need to pass it like below code.
you can use ajax also.
For Post you have to use @RequestBody
try