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

A brief discussion on the placement of script in HTML

I used to think that script could be placed anywh...

Detailed explanation of how to manually deploy a remote MySQL database in Linux

1. Install mysql Run the following command to upd...

Steps to install RocketMQ instance on Linux

1. Install JDK 1.1 Check whether the current virt...

Method of building docker private warehouse based on Harbor

Table of contents 1. Introduction to Harbor 1. Ha...

Correct use of MySQL partition tables

Overview of MySQL Partitioned Tables We often enc...

Example method to view the IP address connected to MySQL

Specific method: First open the command prompt; T...

Detailed explanation of Angular dynamic components

Table of contents Usage scenarios How to achieve ...

Implementation of react loop data (list)

First, let's simulate the data coming from th...

MySQL replication table details and example code

MySQL replication table detailed explanation If w...

Understanding MySQL index pushdown in five minutes

Table of contents What is index pushdown? The pri...

Detailed explanation of MySQL 5.7.9 shutdown syntax example

mysql-5.7.9 finally provides shutdown syntax: Pre...

Mysql database recovery actual record by time point

Introduction: MySQL database recovery by time poi...

CSS3 realizes the effect of triangle continuous enlargement

1. CSS3 triangle continues to zoom in special eff...

Detailed explanation of Vue life cycle

Table of contents Why understand the life cycle W...

Practice of el-cascader cascade selector in elementui

Table of contents 1. Effect 2. Main code 1. Effec...