in the below example, i am trying make post and get requests. the POST request was executed correctly. For the GET request, i exepected to get 2121. but actually, i get nothing which means "this.str" was not set to 2121
is there any way to model a variable to json? normally if the response is an object it will be modelled to json and consequently to the model class. int he below case, the response is a varibale
is there any why to model a vraible as json object
Controller1
@Controller
@ResponseBody
@RequestMapping("/call1")
public class Call1 {
public String str = "inti";
@RequestMapping(value = "/initparam1", method = RequestMethod.POST)
public void initparam1(@RequestBody(required = false) String val) {
this.str = val;
}
@RequestMapping("/getparam1")
public String getParam1() {
return this.str;
}
}
post_request_postman
http://localhost:8085/call1/initparam1?val=2121
executed correctly
get_request_postman
http://localhost:8085/call1/getparam1
result:does not return the value set to str which is 2121