在Tomcat下的war文件中的index.jsp [英] index.jsp in war file under Tomcat

查看:138
本文介绍了在Tomcat下的war文件中的index.jsp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的本地tomcat上运行简单的Web应用程序 - 该应用程序基本上是您在IntelliJ中创建Web应用程序时所获得的,因此目录结构是vanilla。我实际上没有触及index.jsp或web.xml。

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". I am literally not touching either index.jsp or web.xml.

我在Maven下这样做,所以这是我的pom文件:

I am doing this under Maven, so here is my pom file:

<?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. 在maven下构建这个项目: mvn compile install

  2. 我正在复制app_name.war文件从我的本地仓库进入tomcat webapps目录

  3. 运行tomcat: catalina start

  4. I我可以看到我的应用程序在管理器中,但是当我尝试输入它时(或者当我输入 http:// localhost) :8080 / app_name )发生404错误。

  1. Building this "project" under maven: mvn compile install
  2. I am copying app_name.war file from my local repo into tomcat webapps directory
  3. Running 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.

我做错了什么?我不了解一些基本概念或遗漏一些基本的东西?我应该以某种方式明确地将这个index.jsp包含到我的.war文件中吗?如果是这样,我如何在IntelliJ下执行此操作?我真的只是试图运行这个vanilla应用程序而且我的印象是,index.jsp应该是这个.war文件的一部分,它应该自动显示。当我手动执行此操作时,我将在webapps文件夹中创建一些TestDirectory,复制相同的index.jsp文件并将其放在该目录中,然后访问它 http:// localhost:8080 / TestDirectory - 它会自动显示这个index.jsp文件。

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? If so, how do I do that under 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". 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.

抱歉对于,可能,愚蠢的问题,我真的很新,我找不到解决方案。

Sorry for, probably, dumb question, I am really new to this and I couldn't find a solution.

推荐答案

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

remove maven-war-plugin ,after that build and redeploy and test in server

这篇关于在Tomcat下的war文件中的index.jsp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆