【发布时间】:2017-02-04 10:19:14
【问题描述】:
所以我对如何在我的网络应用程序中生成 url 有一点问题。
我在我的服务器上部署了我的“演示”springboot 应用程序作为“demo.war”(它显示为“演示”文件夹)。我还有一个 apache 子域配置为将 demo.myserver.com 映射到 tomcat 上的正确上下文:
<VirtualHost *:80>
ServerAdmin admin@myserver.com
ServerName demo.myserver.com
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / ajp://localhost:8009/demo/
ProxyPassReverse / ajp://localhost:8009/demo/
</VirtualHost>
到目前为止一切顺利。当我转到http://demo.myserver.com 时,它将传递到 tomcat 中的“演示”上下文并加载页面。问题在于如何创建页面中的上下文相关 URL。最终生成的相关 HTML 如下所示:
<form action="/demo/loadDataSet" method="get">
<button type="submit">Load next dataset</button>
</form>
thymeleaf 模板位如下所示:
<form th:action="@{/loadDataSet}" method="get">
<button type="submit">Load next data set</button>
</form>
单击此类按钮后,使用的 URL 为 http://demo.myserver.com/demo/loadDataSet,由于在我的“演示”子域中没有“演示”上下文的映射,该 URL 失败并显示 404。我想知道的是如何生成 html,所以它看起来像这样:
<form action="/loadDataSet" method="get">
<button type="submit">Load next dataset</button>
</form>
谢谢大家
【问题讨论】:
标签: apache tomcat spring-boot thymeleaf