我英文不太好。请理解..
//This is my Spring-mvc-based Controller
@Controller
public class DownloadManageController {
private DownloadManageService downService;
@Autowired
public void setPackService(DownloadManageService downService) {
this.downService = downService;
}
}
//This is my Spring-Bean which should have a dynamic value of contructor
Component
public class DownloadManageService {
private Log log = LogFactory.getLog(DownloadManageService.class);
private FileAccessObject downloadFileAccessObj = null;
DownloadManageService(String downloadInfoFile) {
this.downloadFileAccessObj = new FileAccessObjectImpl(
"d:/dat/download/" + downloadInfoFile);
}
}
当Service注入控制器时...我想使
downloadInfoFile
变量动态取决于请求参数。 最佳答案
我建议您创建一个工厂类,您可以在其中传递所需的路径。