简体   繁体   English

在Tomcat下的war文件中的index.jsp

[英]index.jsp in war file under Tomcat

I am trying to run simple web app on my local tomcat - the app is basically what you get when you crate "web application" in IntelliJ, so the directory structure is "vanilla". 我试图在我的本地tomcat上运行简单的Web应用程序 - 该应用程序基本上是你在IntelliJ中创建“web应用程序”时所获得的,因此目录结构是“vanilla”。 I am literally not touching either index.jsp or web.xml. 我实际上没有触及index.jsp或web.xml。

I am doing this under Maven, so here is my pom file: 我在Maven下这样做,所以这是我的pom文件:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.testapps</groupId>
    <artifactId>Test_App_1</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <webXml>web\WEB-INF\web.xml</webXml>
                </configuration>
            </plugin>
        </plugins>
    </build>


</project>

So here is what I am doing: 所以这就是我在做的事情:

  1. Building this "project" under maven: mvn compile install 在maven下构建这个“项目”: mvn compile install
  2. I am copying app_name.war file from my local repo into tomcat webapps directory 我将app_name.war文件从我的本地repo复制到tomcat webapps目录
  3. Running tomcat: catalina start 跑tomcat: catalina start
  4. I can see that my application IS THERE in manager, but when I try to enter it (or when I just type http://localhost:8080/app_name ) the 404 error occurs. 我可以看到我的应用程序在管理器中,但是当我尝试输入它时(或者当我只输入http:// localhost:8080 / app_name时 )会发生404错误。

What I am doing wrong? 我做错了什么? Am I not understanding some basic concept or missing some basic thing? 我不了解一些基本概念或遗漏一些基本的东西? Should I somehow explicitly INCLUDE this index.jsp into my .war file somehow? 我应该以某种方式明确地将这个index.jsp包含到我的.war文件中吗? If so, how do I do that under IntelliJ? 如果是这样,我如何在IntelliJ下执行此操作? I am literally just trying to run this "vanilla" application and I am under the impression, that index.jsp should be a part of this .war file and it should be displayed "automatically". 我真的只是试图运行这个“vanilla”应用程序而且我的印象是,index.jsp应该是这个.war文件的一部分,它应该“自动”显示。 And when I do it manually, so I will just create some TestDirectory in webapps folder, copy the same index.jsp file and place it in that directory, and then acces it http://localhost:8080/TestDirectory - it automatically displays this index.jsp file as it should. 当我手动执行此操作时,我将在webapps文件夹中创建一些TestDirectory,复制相同的index.jsp文件并将其放在该目录中,然后访问它http:// localhost:8080 / TestDirectory - 它会自动显示index.jsp文件应该如此。

Sorry for, probably, dumb question, I am really new to this and I couldn't find a solution. 对不起,可能,愚蠢的问题,我真的很新,我找不到解决方案。

在构建并重新部署并在服务器中测试之后删除maven-war-plugin

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

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