Making a Spring bean session scoped
Session scoped bean in a Controller – Spring MVC
spring @scope的問題
@Component
@Scope(value="session", proxyMode=ScopedProxyMode.TARGET_CLASS)
public class TestSessionUtils {
private Map<String, Object> dataMap = new HashMap<>();
public Object getData(String key) {
return dataMap.get(key);
}
public void setData(String key, Object value) {
dataMap.put(key, value);
}
}
@Controller
@RequestMapping(value="/login")
public class LoginController extends PicFwBaseController{
private static final Logger log = LoggerFactory.getLogger(LoginController.class);
@Resource private IRsUserService rsUserService; // 使用者Service
@Autowired private TestSessionUtils testSessionUtils;
}
沒有留言:
張貼留言