Count.java:
@Component
@Scope(value = "session",proxyMode = ScopedProxyMode.TARGET_CLASS)
public class Count {
Integer i;
public Count() {
this.i = 0;
}
Controller:
@Controller
public class GreetingController {
@Autowired private Count count;
@RequestMapping("/greeting")
public String greetingForm(Model model) {
if(count.i == null) i == 0;
else i++;
model.addAttribute("count",String.valueOf(count.i));
return "greeting";
}
}
But every i run this controller (/greeting), it always increase the i even when I close the browser, so how can i use this Session Scoped Component in Singleton Controller?