在项目中,由于Excel文件过大,使用http会出现超时的现象,所以使用websocket来生成Excel,文件生成时可自动返回文件地址,使用起来比较方便。
但是由于在websocket中需要使用到service,所以打算使用
@Resource
private UserService userService;
来获取到service,但是发现最终 userService == null;
这个问题怎么解决呢?
1. 使用
ContextLoader.getCurrentWebApplicationContext().getBean(BeanName.class);
例如:
private CustomerService customerService = ContextLoader.getCurrentWebApplicationContext().getBean(CustomerService.class);
{{ cmt.username }}
{{ cmt.content }}
{{ cmt.commentDate | formatDate('YYYY.MM.DD hh:mm') }}