我来到 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}/" />
使用全局 javascript 变量并将其附加到所有网络调用中
传递
baseUrl
作为模板的参数。然后:<a th:href="${baseUrl + '/my/uri?maybe=' + someParam}"
.
希望对您有所帮助。
关于spring-boot - 在 tomcat 上部署 spring boot 应用程序,我应该替换我所有应用程序的 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56252811/