'why sites are not displayed correctly on heroku

I'm new to Java development. I made an application that checks the functionality of sites. When you start the Spring application, all sites work and display correctly. I deployed the application to Heroku and the sites no longer display correctly. Most likely the problem is due to Heroku, but how to fix it?

Controller

public class DetektController {
    private final SiteService siteService;
    private final GetAllService getAllService;

    public DetektController(SiteService siteService, GetAllService getAllService) {
        this.siteService = siteService;
        this.getAllService = getAllService;
    }

    private String getStatus(boolean result) {
        if (result) {
            return " OK";
        } else {
            return "FAIL";
        }
    }

    @GetMapping("/all")
    String getAll(Model model) {
        List<CheckResult> checkResults = getAllService.getUriAndStatus();
        List<CheckResultDto> checkResultDtos = new ArrayList<>();

        for (CheckResult checkResult : checkResults) {
            checkResultDtos.add(new CheckResultDto(checkResult.getUri(), getStatus(checkResult.isStatus())));
        }

        model.addAttribute("sites", checkResultDtos);
        return "all";
    }

    @GetMapping("/add")
    String addSite() {
        return "add.html";
    }

    @PostMapping("/add")
    String addNewSite(@ModelAttribute AddNewSiteRequestDto request) {
        Site site = new Site(null, request.getSite());
        siteService.save(site);
        return "redirect:/all";
    }

    @GetMapping("/deleteAll")
    String deleteAllSite() {
        siteService.deleteAllSite();
        return "redirect:/all";
    }

    @GetMapping("/deleteByUri")
    String deleteByUri(@RequestParam String uri) {
        siteService.deleteByUri(uri);
        return "redirect:/all";
    }

Service

public class SiteService {

    private final SiteRepositoryDao siteRepository;

    public Site save(Site site) {
        return siteRepository.save(site);
    }

    public Iterable<Site> getAll() {
        return siteRepository.findAll();
    }

    public void deleteAllSite() {
        siteRepository.deleteAll();
    }

    public void deleteByUri(String uri) {
        siteRepository.deleteByUri(uri);
    }

@Service
public class GetAllService {
    private final InetAddressCheckerService inetAddressCheckerService;
    private final SiteService siteService;
    private final int timeout;
    private final SiteConditionRepositoryDao siteConditionRepositoryDao;

    public GetAllService(
        InetAddressCheckerService inetAddressCheckerService,
        SiteService siteService,
        @Value("${url-checker.timeout}") int timeout,
        SiteConditionRepositoryDao siteConditionRepositoryDao
    ) {
        this.inetAddressCheckerService = inetAddressCheckerService;
        this.siteService = siteService;
        this.timeout = timeout;
        this.siteConditionRepositoryDao = siteConditionRepositoryDao;
    }

    public List<CheckResult> getUriAndStatus() {
        Iterable<Site> sites = siteService.getAll();
        List<CheckResult> checkResults = new ArrayList<>();
        List<SiteCondition> siteConditions = new ArrayList<>();

        for (Site site : sites) {
            boolean result = inetAddressCheckerService.checkUriAddress(URI.create(site.getUri()), timeout);

            CheckResult checkResult = new CheckResult(site.getUri(), result);
            SiteCondition siteCondition = new SiteCondition(null, site.getUri(), result, LocalDateTime.now());

            siteConditions.add(siteCondition);
            checkResults.add(checkResult);
        }
        siteConditionRepositoryDao.saveAll(siteConditions);
        return checkResults;
    }

@Service
public class InetAddressCheckerService {

    public boolean checkUriAddress(URI address, int timeOut) {
        boolean result;
        try {
            result = InetAddress.getByName(address.getHost()).isReachable(timeOut);
            return result;
        } catch (IOException e) {
        }
        return false;
    }
}

веб отображение

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <link href="css/style1.css" rel="stylesheet">
    </head>
    <body>
    <h1>
        Результат проверки работоспособности сайтов
    </h1>
    <h4>
    <form action="/deleteAll" method="get" onsubmit="return checkDeleteAll()">
        <input type="submit" value=" Delete ALL">
    </form>
    <script>
        function checkDeleteAll(){
            return window.confirm("Точно удалить все записи?")
        }
    </script>
    </h4>
    <table>
        <tr>
            <th>Uri</th>
            <th>Status</th>
            <th>Operation</th>
        </tr>
        <th:block th:each="site : ${sites}">
            <tr>
                <td th:text="${site.uri}"></td>
                <td th:text="${site.status}"></td>
                <td>
                    <form th:action="@{deleteByUri}" method="get">
                        <input type="hidden" name="uri" th:value="${site.uri}"/>
                        <input type="submit" value="Delete" class="btn btn-danger"/>
                    </form>
                </td>
    
            </tr>
        </th:block>
    </table>
    </body>
</html>

enter image description here

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source