tomcat - Intellij IDEA - 为 tomcat 中的多个模块定义单独的上下文根

标签 tomcat intellij-idea module

Tomcat 和/或 Intellij IDEA 让我抓狂......

简而言之,我有一个包含 2 个模块的项目,它们都有使用图像、脚本等绝对路径的 jsp 和/或 html 文件...

Project structure

当我用斜杠(“/”)部署第一个时,我可以看到我的图像,我的脚本被完美加载,但是,部署为(“/module2”)的模块二不加载图像,脚本和没有绝对路径,因为上下文根是服务器,而不是工件...

Error because the module context isn't inserted in the absolute path

这是 IntelliJ IDE 项目,它很小,反射(reflect)了我解释的行为。

Project with 2 modules

有人可以帮我解决这个问题吗?

最好的问候, 亚历克斯弗洛林多

最佳答案

请查看this answer .

IntelliJ IDEA 对此有一个快速修复:

fix1

fix2

在Alt+Enter、Enter之后,你会得到代码改为:

<img src="${pageContext.request.contextPath}/imgs/user_bg1.png">

您可以在整个项目中运行此检查并对所有受影响的代码部分批量应用快速修复。

关于tomcat - Intellij IDEA - 为 tomcat 中的多个模块定义单独的上下文根,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54937370/

相关文章:

java - 即使 JAVA_HOME 路径正确,Tomcat 也没有运行

java - 尝试嵌入exist-db时出现问题

git - IntelliJ IDEA GitHub 集成创建存储库,但尝试推送时出现“"couldn' t 授权”错误

c - 内核模块中的 GMP

.net - 如何从 .NET 应用程序运行 "sudo su tomcat"

spring - jms 连接工厂 javax.naming.NamingException : Could not create resource factory instance

intellij-idea - Dart SDK 在哪里? |错误 : the folder specified as the Dart SDK home does not exists

python - 了解 datetime 模块中 datetime 类方法的用法,而无需创建实例

iis-7 - IIS7 模块 - 托管还是 native ?

tomcat - 在 IntelliJ 上运行我的应用程序时出错