spring-boot - 在 tomcat 上部署 spring boot 应用程序,我应该替换我所有应用程序的 url

标签 spring-boot tomcat deployment

我来到 tomcat 上部署我的 spring boot 应用程序,我关注了这个网站 https://www.mkyong.com/spring-boot/spring-boot-deploy-war-file-to-tomcat/

但是我对我的 html 文件进行了更改: 我的申请名称是:GestionRetardApp它的版本是“0.0.1” 在更改我的 html 文件之前,我以这个文件为例:

<!DOCTYPE html>
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
    layout:decorate="layout/layout">
<head>
<meta charset="UTF-8" />
</head>
<body>
    <div layout:fragment="content">
        <center>
            <form action="/searchByName">
                <table>
                    <tr>                        
                        <td><select name="nomprenom" class="form-control">
                                <th:block th:each="p : ${rhEmployeesList}">
                                    <option th:text="${p.nomPrenom}" th:value="${p.nomPrenom}"></option>
                                </th:block>
                        </select></td>
                    </tr>
                </table>
                <input type="submit" value="Rechercher">
            </form>
        </center>
    </div>
</body>
</html>

我发现自己被迫改变<form action="/searchByName">

<form action="/GestionRetardApp-0.0.1/searchByName">

我为我拥有的所有网址都这样做了! 有没有其他方法可以保留我的默认代码而不更改我的 html 文件?

最佳答案

有几种方法可以做到...... 1. 使用 <base href="${pageContext.request.contextPath}/" />

  1. 使用全局 javascript 变量并将其附加到所有网络调用中

  2. 传递 baseUrl作为模板的参数。然后:<a th:href="${baseUrl + '/my/uri?maybe=' + someParam}" .

希望对您有所帮助。

关于spring-boot - 在 tomcat 上部署 spring boot 应用程序,我应该替换我所有应用程序的 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56252811/

相关文章:

java - RestTemplate 访问 Response 中的元素

spring-boot - 在Spring Boot中为liquibase配置dataSource

sql - ssdt 部署后脚本运行一次

php - Azure Web 应用程序 Mcrypt 安装

java - 优化 Spring RestControllerAdvice 多个异常

java - url解码导致tomcat中出现问号

java - DSpace,超过 1000 比特流的错误编辑项

java - 在 tomcat 上运行时 ClassLoader.getSystemResourceAsStream 不工作

sql-server - 使用 PowerShell 在客户计算机上部署 SSRS 报告

spring-boot - Feign/Eureka 客户端不传递 X-Forwarded-For header