0
我正在使用Spring Batch,并添加了一项新功能来过滤作业执行情况。我所做的就是创建一个新的控制器:Spring批处理:对我的自定义控制器使用executions.ftl
@Slf4j
@Controller
public class FilteredJobExecutionResource {
@Autowired
@Qualifier("filteredJobExecutionService")
@Getter
@Setter
private FilteredJobExecutionService filteredJobExecutionService;
private TimeZone timeZone = TimeZone.getDefault();
public FilteredJobExecutionResource() {
super();
}
@RequestMapping(value = { "/jobs/executions.*/filter/{filter}" }, method = RequestMethod.GET, produces = "application/json")
public @ModelAttribute("jobExecutions")
Collection<JobExecutionInfo> list(ModelMap model, @PathVariable("filter") String filter,
@RequestParam(defaultValue = "0") int startJobExecution,
@RequestParam(defaultValue = "20") int pageSize) throws Exception {
int total = filteredJobExecutionService.countJobExecutions(filter);
TableUtils.addPagination(model, total, startJobExecution, pageSize, "JobExecution");
Collection<JobExecutionInfo> result = new ArrayList<>();
for (JobExecution jobExecution : filteredJobExecutionService.listJobExecutionsByFilter(filter, startJobExecution, pageSize)) {
result.add(new JobExecutionInfo(jobExecution, timeZone));
}
return result;
}
}
这个类,非常类似于Spring Batch的JobExecutionController
,但加入了PathVariable
,过滤器。我现在面临的问题是,我希望我的控制器使用像JobExecutionController
现有的JSON/executions.ftl做,但我得到以下错误:
Could not resolve view with name 'jobs/executions.json/filter/662' in servlet with name 'RESTServlet'
任何想法,我怎么能解决这个问题呢?
感谢
我发现了一个部分解决方案: ' \t \t <属性名= “属性”> \t \t \t <道具合并= “真”> \t \t \t \t <丙键= “体”> /经理/作业/ JSON/executions.ftl \t \t \t \t \t \t ' 但它只适用于过滤器值为662的请求。任何方式来做任何值? –
user1990218