我有2个警告: - 第一个是:
HELPDESKGESTION2\src\java\glpi\filter\LoginFilter.java:289: warning: [unchecked] unchecked call to put(K,V) as a member of the raw type java.util.Hashtable
localParams.put(key, value);
^
- 第二个是:
HELPDESKGESTION2\src\java\glpi\filter\LoginFilter.java:292: warning: [unchecked] unchecked call to put(K,V) as a member of the raw type java.util.Hashtable
localParams.put(name, values);
^
Code ho生成此警告的是:
public void setParameter(String name, String []values) {
if (debug) System.out.println("LoginFilter::setParameter(" + name + "=" + values + ")" + " localParams = "+ localParams);
if (localParams == null) {
localParams = new Hashtable();
// Copy the parameters from the underlying request.
Map wrappedParams = getRequest().getParameterMap();
Set keySet = wrappedParams.keySet();
for (Iterator it = keySet.iterator(); it.hasNext(); ) {
Object key = it.next();
Object value = wrappedParams.get(key);
localParams.put(key, value);
}
}
localParams.put(name, values);
}
答案 0 :(得分:25)
替换:
localParams = new Hashtable();
使用:
localParams = new Hashtable<String,String>();
我假设您有一个如下所示的全局变量:
private Hashtable localParams;
将其替换为:
private Hashtable<String,String> localParams;
如果您进行了更改,我建议警告将消失,但您还必须用String替换所有对象;