To contextualize :
There is a remote directory, clearing-dit\logs
, which has a series of logs ( portal.log
, test.log
, ...). This directory is mapped to an HTML page, where all its .log's
are displayed. Once one of them is clicked, its respective content is displayed.
ThiscontentisloadedthroughtheHTML/thymeleafpage,whichcallsthecontentsofalog.java
.
<pth:utext="${log.content}">Log content</p>
The need to make this content continue to be displayed (its updates) every 5 seconds, in real time and without having to update the entire page, only updating where the content is. I've been researching and seen that I can / do it through an AJAX, but the concept of it is somewhat vague to me.
My question:
How do I make / call the AJAX url? I know that in AJAX there are two type fields - > POST / GET and url - > (?), but I can not understand how this crossover works, because in theory, if it were possible to call the method that displays the current content:
@RequestMapping(value = "/log", method = RequestMethod.POST)
public String logContent(@Valid Log log, BindingResult bindingResult, Map<String, Object> model) {
if (log.getInitLine() == 0 && log.getFinalLine() == 0) {
try {
fileNumberLines(log);
log.setContent(getLogContentByRange(0, log.getInitLine(), log.getFinalLine(), logsDir + "/" + log.getFilename()));
} catch (IOException e) {
logger.error(e.getMessage());
}
} else {
log.setContent(getLogContentByRange(0, log.getInitLine(), log.getFinalLine(), logsDir + "/" + log.getFilename()));
}
model.put("path", logsDir);
model.put("log", log);
model.put("currentPage", "logs");
model.put("root", root);
return "log";
}
Every 5 seconds, I would solve the problem.