thymeleaf模板返回异常问题Springboot问题
org.thymeleaf.exceptions.TemplateInputException: Error resolving template "index/copyIndex", template might not exist or might not be accessible by any of the configured Template Resolvers
@Slf4j@RequestMapping(value = "index")
@Controller
public class IndexController {
@Autowired
private CommonIndexService indexService;
/**
* 通过定时任务进行每天备份索引(doctor)
* @param indexName
* @return
* @throws Exception
*/
@PostMapping(value = "/copyIndex")
public void copyIndex(@RequestParam("indexName") String indexName) throws Exception{
}
}
解决:在controller层请求处理完了返回时,没有使用@RestController或@ResponseBody而返回了非json格式。这种情况下返回的数据thymeleaf模板无法解析,直接报错。
@Slf4j@RequestMapping(value = "index")
@RestController
public class IndexController {
@Autowired
private CommonIndexService indexService;
/**
* 通过定时任务进行每天备份索引(doctor)
* @param indexName
* @return
* @throws Exception
*/
@PostMapping(value = "/copyIndex")
public void copyIndex(@RequestParam("indexName") String indexName) throws Exception{
log.info("indexName:{}", indexName);
}
}
以上是 thymeleaf模板返回异常问题Springboot问题 的全部内容, 来源链接: utcz.com/z/513247.html