问题描述
写文件下在的INTERCEPTOR时 如下:public class DownLoadIntercept extends AbstractInterceptor {@Overridepublic String intercept(ActionInvocation invocation) throws Exception {invocation.addPreResultListener(new PreResultListener(){@Overridepublic void beforeResult(ActionInvocation invocation,String resultCode) {Map<String,ResultConfig> 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<String,String> 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")都不行?请教! 问题补充:dream_hanker 写道
解决方案
这样调用new ResultConfig.Builder().addParam("contentType","application/msword");
解决方案二:
finalResultConfig以及Builder没有别的相关方法吗?可否将其方法帖全?