ZHENGQXTOM 2011-05-17 11:53
浏览 322
已采纳

静态内部类的调用

写文件下在的INTERCEPTOR时 如下:
public class DownLoadIntercept extends AbstractInterceptor {
@Override
public String intercept(ActionInvocation invocation) throws Exception {
invocation.addPreResultListener(new PreResultListener(){
@Override
public void beforeResult(ActionInvocation invocation,String resultCode) {
Map resultsMap=invocation.getProxy().getConfig().getResults();
ResultConfig finalResultConfig=resultsMap.get(resultCode);
finalResultConfig.Builder.addParam("contentType","application/msword")

}});
return null;
}
}
finalResultConfig.Builder.addParam("contentType","application/msword")这句显示编译错误
查看了一下ResultConfig这个类的源代码
public class ResultConfig extends Located implements Serializable {
private Map params;
...
...
public static final class Builder {
...
....
public Builder addParam(String name, String value) {
target.params.put(name, value);
return this;
}
}
ResultConfig 类里面有一个MAP params 但类没有SET MAP方法
类是用静态内部类Builder 的方法addParam来设置的
但问题是怎样调用这个内部类的方法?
ResultConfig.Builder.this.addParam("contentType","application/msword")
都不行?
请教!

  • 写回答

2条回答 默认 最新

  • tangpython 2011-05-17 12:41
    关注

    这样调用
    [code="java"]
    new ResultConfig.Builder().addParam("contentType","application/msword");
    [/code]

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?