Idea packaged into war package deployed to tomcat and access path issues (illustration and text)

Idea packaged into war package deployed to tomcat and access path issues (illustration and text)

The most important thing for idea to package a web project into a war is to configure atrificats.

First open file -> project structure

After creation, the output directory is the path of the output war package. The name can be anything you want, then click the green + to open the directory content

Select the webapp directory and remember to check include in project build

After clicking OK, create a new configuration

Select artificats

In this way, even if the configuration is completed, after clicking run to execute, just find the war package in the folder set in the previous output directory. Put the war package in the webapp directory of tomcat, and then start tomcat to access the project.

The access address of the project is localhost:8080/your war package name/index

What I want to say here is that since the name of the war package determines the access address, when using pure html+css+js to write a page, it is best to add your project name (that is, your final war package name) to the resource reference address of the page, for example, referencing a js file:

<link rel="stylesheet" href="/layui/css/layui.css" media="all" />

At this time, if you hold down the ctrl key and hover the mouse over the file path, there will be a clickable prompt.

However, when the project is deployed on tomcat, the war package is equivalent to adding a folder named your war package. At this time, the original reference will prompt that the file cannot be found. At this time, we should reference it like this:

<link rel="stylesheet" href="/war package name/layui/css/layui.css" media="all" />

When your reference address contains .., for example:

<script type="text/javascript" src="../../page/user/editUser.js"></script>

It should be modified like this:

<script type="text/javascript" src="../../war package name/backstage/page/user/editUser.js"></script>

But here comes the problem. When configured in this way, the file can be found when deployed to tomcat, but after starting tomcat debugging in local idea development, the file cannot be found. At this time, you should configure the application context and start it. And make sure it is consistent with the file path when deployed to Tomcat, so there is no need to modify the address of the front-end page when deploying to Tomcat. (jsp does not need to consider this problem because jsp can obtain the root path).

If the application context is just "/", then it is equivalent to placing all files under tomcat's webapp and accessing them directly through localhost:8080/file.

This is the end of this article about packaging idea into a war package and deploying it to Tomcat and the access path problem (detailed explanation with pictures and text). For more relevant idea war package deployment to Tomcat content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • idea combines docker to realize image packaging and one-click deployment
  • A brief analysis of SpringBoot packaging and uploading to docker and implementing multi-instance deployment (IDEA version)
  • How to package jar with Intellij idea2020
  • When running the jar packaged by idea, it reports "There is no main manifest attribute in XXX"
  • The complete steps to package the idea project into a jar file
  • Detailed explanation of various ways to package jar with idea
  • How to package the project into docker through idea

<<:  js method to realize shopping cart calculation

>>:  Summary of SQL query optimization knowledge points for MySQL tens of millions of big data

Recommend

Detailed explanation of custom swiper component in JavaScript

Table of contents Effect display Component Settin...

In-depth understanding of MySQL long transactions

Preface: This article mainly introduces the conte...

Implementation of Nginx filtering access logs of static resource files

Messy log Nginx in daily use is mostly used as bo...

MySQL 5.7.18 download and installation process detailed instructions

MySql Download 1. Open the official website and f...

Example of how to configure nginx to implement SSL

Environmental Description Server system: Ubuntu 1...

MySQL 8.0 Window Function Introduction and Summary

Preface Before MySQL 8.0, it was quite painful to...

Solution to the problem of repeated triggering of functions in Vue project watch

Table of contents Problem description: Solution 1...

Introduction to HTML_PowerNode Java Academy

What is HTML? HTML is a language used to describe...

How to monitor array changes in JavaScript

Preface When introducing defineProperty before, I...

jQuery combined with CSS to achieve the return to top function

CSS Operations CSS $("").css(name|pro|[...

Oracle deployment tutorial in Linux environment

1. Environment and related software Virtual Machi...

Difference between querySelector and getElementById methods in JS

Table of contents 1. Overview 1.1 Usage of queryS...