I have built a web application in Spring Boot that has a form and besides the values from the form that it inserts in the database it takes from the header the username. This is the code from the Controller:
@PostMapping("/BilantErr/")
public String postIndex(@RequestParam(name = "cui") String cui, @RequestParam(name = "an_raportare") String anRaportare,
@RequestParam(name = "perioada") String perioada,
@RequestHeader("iv-user") String operator, @RequestParam(name = "motivatie") String motivatie, Model model) {
String page = "";
//String operator = "serban";
try {
if (repository.insert(cui, anRaportare, operator, motivatie, perioada) == true) {
page = "success";
} else {
page = "error";
}
} catch (Exception e) {
Logger logger = LoggerFactory.getLogger(BilantErr.class);
}
return page;
}
The error that I am getting is : Resolved [org.springframework.web.bind.MissingRequestHeaderException: Required request header 'iv-user' for method parameter type String is not present]
What may be the problem ? There is an application already built in JSF that works and takes the user from the header and I have to replace it with a Spring app. What am I doing wrong ? Thanks