我有一个 Spring BeanFactory,我需要向它注入 httpHeaders。
public class SpecificFactoryBean extends SomeFactoryBean<Exception> {
@Context
private HttpHeaders httpHeaders;
protected SpecificFactoryBean() {
super(Exception.class);
}
@Override
protected void doRegistration(RegistryBuilder<Exception> registryBuilder) {
registryBuilder.registerMapper(WebApplicationException.class, new ExceptionMapper<WebApplicationException>() {
@Override
public int map(WebApplicationException e) {
httpHeaders.getSomeInfo();
return 3;
}
});
}
}
现在@Context
不起作用,那我该怎么做?