When using AJPProxy and setting the context path to /, relative paths such as css/js are not read well

Asked 1 years ago, Updated 1 years ago, 98 views

The environment is
java8
Tomcat8
SpringMVC That's it.

When creating a web application, the VIEW style sheet and JavaScript's relative path are offset.

Set the context path to " / " and
http://Domain/
I would like to access the TOP page in
DocBase must be written in server.xml.

 http:// domain/context path/

I don't think I can connect without .
Therefore, using apache's AJP proxy,

http:// domain/

http:// domain:8080/context path

I tried to transfer it to
The path of js,css to import is

http://Domain/js/~~~.js

or

http://Domain/css/~~~.css

It has become and cannot be captured successfully.

reluctantly add DocBase to server.xml and
The context path has been set to / .
Is there any other good way to set it up independently of the operating server?

java apache spring tomcat

2022-09-30 20:12

1 Answers

In Apache's httpd.conf or proxy_ajp settings

<IfModule proxy_ajp_module>
  <Location/>
    ProxyPassajp://localhost:8009/war Context Path/
  </Location>
</IfModule>

I think it will be all right if you write down .
The point is that Location specifies the context path for the root path (/) → Tomcat war.

Of course, it's not good to mention the context path in the path of css/js on the web application side.

I hope it will be helpful


2022-09-30 20:12

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.