简体   繁体   English

从外部访问WAR文件

[英]Accessing WAR file from outside

We have static HTML files which are outside of the WAR file. 我们拥有WAR文件之外的静态HTML文件。 The files are "index.html", "about_us.html", "news.html". 这些文件是“ index.html”,“ about_us.html”,“ news.html”。 Lets say our war file name is "MyWarProject". 可以说我们的战争文件名为“ MyWarProject”。 Right now we launch the tomcat and directly access the WAR file using 现在,我们启动tomcat,并使用以下命令直接访问WAR文件

localhost:8080/MyWarProject/

After we host it, the lcoalhost part will be replaced by a domain name. 托管之后,lcoalhost部分将被域名替换。

But what we actually need is that user first access the "index.html", after that he click on "SIGN-UP" button to access the WAR file. 但是我们真正需要的是用户首先访问“ index.html”,然后单击“ SIGN-UP”按钮访问WAR文件。 How can I do this? 我怎样才能做到这一点?

Actually, WAR files get unzipped inside the webapps folder and we can simply deal with HTML files after that. 实际上,WAR文件在webapps文件夹中解压缩,然后我们可以简单地处理HTML文件。 If the HTML is not highly affecting the rest, we can even add/remove them without issue. 如果HTML对其余部分的影响不大,我们甚至可以添加/删除它们而不会出现问题。

How's about host the HTML files in another context (eg, localhost:8080/HTMLProject/) and you can have a link in the index.html to the "MyWarProject" 如何将HTML文件托管在另一个上下文中(例如localhost:8080 / HTMLProject /),您可以在index.html中链接到“ MyWarProject”

For that, you just have to create a new folder inside Tomcat's webapps for HTMLProject 为此,您只需要在Tomcat的webapps中为HTMLProject创建一个新文件夹。

You can navigate to the signup page by redirect the user via javascript. 您可以通过javascript重定向用户来导航至注册页面。 Example code below. 下面的示例代码。 Provide a button to the user on index.html on click the flow hits the signup page 在index.html上向用户提供一个按钮,单击该流会单击注册页面

index.html 的index.html

<!DOCTYPE html>
<html>
<head>
<script>
function moveToSignUp() {
    window.location.assign("http://yourdomain/signup.jsp")
}
</script>
</head>
<body>

<input type="button" value="Move to SignUp" onclick="moveToSignUp()">

</body>
</html>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM