您的位置:首页 > 编程语言 > Java开发

spring4 获取泛型信息

2015-05-18 00:23 232 查看
public interface TestService<Question> {

public String test();

}


@Service
public class TestServiceImpl implements TestService<Question> {

@Override
public String test() {
String abc = "abc";
return abc;
}

}


@Controller
@RequestMapping("/test")
public class TestController {

@Autowired
private TestService<Question> testService;

@RequestMapping
public String index(){
testService.test();
ResolvableType resolvableType2 =  ResolvableType.forField(ReflectionUtils.findField(TestController.class, "testService"));
System.out.println(resolvableType2.getGeneric(0).resolve());
return "index";
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐