Meine Post-Methode wird aufgerufen, aber mein Profil ist leer. Was ist falsch an diesem Ansatz? Muss ich @Requestbody verwenden, um RestTemplate zu verwenden?RestTemplate Post für Entität
Profile profile = new Profile();
profile.setEmail(email);
String response = restTemplate.postForObject("http://localhost:8080/user/", profile, String.class);
@RequestMapping(value = "/", method = RequestMethod.POST)
public @ResponseBody
Object postUser(@Valid Profile profile, BindingResult bindingResult, HttpServletResponse response) {
//Profile is null
return profile;
}
Ist Ihr Controller mit dem 'user' Teil des Pfades in' @ RequestMapping' versehen? Weil Ihr metohd annotiert Punkte auf '/', die nicht auf '/ user /' ohne die zusätzliche Controller-Anmerkung reagieren wird. –
@ nicholas.hauschild Ja. Ich betrete die Controller-Methode. Das Problem ist, dass das Profil in der tatsächlichen Methode null ist. – pethel