I am learning spring boot, and i developed the below simple example. I would like to annotate a class as Controller using @Controller. this class has constructor and I want to have access to GreetingFromDeuController as shown:
http://localhost:8080:/GreetingFromDeuController?str = "hi"
the error i am receiving is
@RequestMapping is not applicable on a constructor
please let me know how to solve.
code:
@Controller
@RequestMapping("/GreetingFromDeuController")
public class GreetingFromDeuController {
private String str;
@RequestMapping("/GreetingFrom/deu")
GreetingFromDeuController(@RequestParam(value = "str") String str) {
this.str = str;
}
@RequestMapping("/GreetingFromDeuController")
public String getGreetingFromDeu() {
return this.str;
}
}