Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Explain in detail how tomcat sets the default path to cause project url conflict resolution

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

preface

Tomcat as a java container is very good, but there will still be some avoid the pit, in this record a pen.

START

problem

URL path conflict after deploying multiple projects

scenario description

1. There are two projects under webapps, projectA and projectB. Except for the management information interface, the other two projects have security verification mechanism.

2. projectA Because there is no separation between the front and back, static resources also exist in java projects. When making interface requests in static resources, the package name is not written, such as login,js code will concatenate the server ip+ port + url(/login) currently set, without adding/projectA before/login, so there is no problem in testing on the local machine, only when deployed. That's a problem, too. Let's get to it.

projectB is a working project

Solution for Scenario 2

Open the tomcat configuration file, add the default access path set to the server in the tag, so you avoid the package name, but this method is very irregular, not recommended.

code interpretation

path and doBase together represent the specified package path, which can be unloaded directly from docBase for simplicity. Restart tomcat and test that ip+port can access resources in this package, however url ambiguity occurs when accessing resources in other packages. Originally intended to access projectB, but mapped to projectA project. Only some urls will have this problem.

Then our solution is to install another tomcat and deploy only projects that require direct path mapping

So go back to tomcat directory,cp command copy

$> cp -r tomcat8.5/ tomcat8.6/

Then move projectA from tomcat 8.5 to tomcat 8.6.

Delete tomcat 8.5

In tomcat 8.6, you need to make the following changes to service.xml.

Change shutdown to port 8006, as long as it is different from tomcat 8.5 and the port does not conflict.

Change the port corresponding to the request, the principle is the same as above

The content of the tag copied over, need to modify the corresponding mapping path.

In this way, two tomcats can run at the same time, and start and close do not affect each other.

The above is all the content of this article, I hope to help everyone's study, but also hope that everyone a lot of support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report