如下:
@Controller
public class MyController{
@Autowired
private HttpSession session;
@RequestMapping("/hello"){
return "hello world";
}
}
通常来说, 注入通过在 xml 声明 Bean 或是 注解 @Component 也好, 就是 setter 或 constructor 也行, 但是 Httpsession 或是 HttpServletRequest 都没有任何注入过程或是声明, 直接用 @Autowired 就使用了.
有的说 Spring 它给代理了, 但是也查了很多, 找不到完整的解释. 有点困惑..