Angular:
function(team, team) { return this.http.put('/api/tradeTeam/', team,
team2).map(res => res.json()); }
Spring/Hibernate
@RestController
@Controller
public class MainController {
@RequestMapping(value = "/api/tradeTeam/", method = RequestMethod.PUT)
public List<Team> TradeTeam(@RequestBody Team team, Team team2) {
return teamService.TradeTeam(team, team2);
}
}
What am I doing wrong? My Service is set up correctly.
My error is:
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause
The problem is that you are passing the team2 as a third parameter for the http.put function, which is taken as options (not for body where you need it).
You should send something like that (and I think this will need some more work also on the backend)
function(team, team2) {
return this.http.put('/api/tradeTeam/', {teams: [team, team2]})
.map(res => res.json());
}
See: Angular HTTP Client Docs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With