Set context root in Spring Boot web application

1.3k Views Asked by At

Hello I am building a web application in Spring Boot and Thymeleaf.

I need to set the context root of the app which I have set like this:

@GetMapping ("/CautareTelefonMail/" )
public String getHello() {

return "index" ;
}



@PostMapping("/")
public String postDbRequest(@RequestParam(name="text2",required = false)String telefon, Model model, @RequestParam(name="email",required = false)String email) throws Exception {

   /// code that does the searching in the database
    
   return "index";
}

This way when I access http://localhost:8080/CautareTelefonMail/ it shows me the form and it works. But when I get the results in the table the address in the address bar is just http://localhost:8080. I need it to be http://localhost:8080/CautareTelefonMail/.

How can I do this ?

This is what I`ve tried:

@PostMapping("/CautareTelefonMail")
public String postDbRequest(@Reques...etc.

But when I modify it like this it does not return anything it returns the error page.

Can please someone give me an ideea how to do it ? Also in the html in the form I have at action="/"

0

There are 0 best solutions below