问题初衷:如何根据参数变换方法的返回类型(参数为 类)
解决方案采用泛型解决(<T>)
解决方案:
下面方法是放在工具类(例:YslRequestUtil)
1 public <T> T response(Object requestentity, T responseentity, String Url, String metodname){
2 //强转传递参数
3 T hfGetPolicyResponse = (T) resxstream.fromXML(result);
4 System.out.println(hfGetPolicyResponse);
5
6 return hfGetPolicyResponse;
7 }
1 GetPolicyByRtPatRes getPolicyByAirLine = yslRequestUtil.response(getPolicyByAirLineReq, new GetPolicyByRtPatRes(), "http://www.baidu.com", "metodname");