简体   繁体   中英

Saving data over multiple pages with java web-application

I was looking for a way to store information so I can use a specific variabele multiple times. If the user gives his/her name, I want to be able to set the name at the top of each page.

I already tried to use this in my controller.

public String login(Model model, HttpServletRequest request) {
    gebruikersnaam = request.getParameter("gebruikersnaam");
    gebruikerRepository.gebruikersnaamOpslaan();
    gebruikerRepository.getGebruiker(gebruikersnaam);
    return "/index";
}

Thank you in advanced Jonas

Assuming gebruikerRepository is the pojo class, you need to use a setter method like gebruikerRepository.setGebruiker(gebruikersnaam) to set the name into variable gebruiker .

Use gebruikerRepository.getGebruiker() to retrieve the variable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM