使用Intellij 10.X和tomcat 6.X修改后热部署JSP

发布于 2024-10-30 13:02:14 字数 741 浏览 4 评论 0原文

我有一个 Hello-World 应用程序,其中包含一个 java 类和一个 jsp。 JSP 打印出一些嵌入在 JSP 中和来自 java 类的文本。 (它打印出两件事)

我按照此处的指示创建和部署我的应用程序及其(大部分)有效!我能够调用 JSP 并且它可以正确显示页面。在按下 Intellij 重新加载按钮后,我还可以热交换 java 类中的更改。

问题:如果我更改 JSP,它不会反映在浏览器中。

我已经验证了以下内容:

  • Tomcat/conf 目录中的 web.xml 不会覆盖“development”值。默认为 true。
  • HelloWorld\web\META-INF\context.xml 和 Tomcat\conf\context.xml 中的 context.xml 都有 reloadable=true
  • J​​SP 从 C:\code\HelloWorld\web\index.jsp 复制到 C: \code\HelloWorld\out\artifacts\HelloWorld_war_exploded\index.jsp 立即发生任何更改
  • 这不是浏览器缓存问题有

什么想法吗?

I have a Hello-World application with one java class and one jsp. The JSP prints out some text that is embedded in the JSP and from the java class. (It prints out two things)

I followed the directions here to create and deploy my application and it (mostly) WORKS! I am able to invoke the JSP and it properly displays the page. I am also able to hotswap changes in the java class after I press the Intellij reload button.

Problem: If I change the JSP, it does not get reflected in the browswer.

I have verified the following:

  • web.xml in the Tomcat/conf directory does not override the "development" value. The default is true.
  • context.xml in both the HelloWorld\web\META-INF\context.xml and Tomcat\conf\context.xml has reloadable=true
  • That the JSP is copied from C:\code\HelloWorld\web\index.jsp to C:\code\HelloWorld\out\artifacts\HelloWorld_war_exploded\index.jsp on any change immediately
  • Its not a browser cache issue

any thoughts?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

随风而去 2024-11-06 13:02:14

当我回答这个问题时,IntelliJ IDEA 的版本是 13.0.2。自从提出这个问题以来,选项略有不同。简而言之,通过项目的“运行/调试配置”面板:

  1. 确保您的项目设置为部署为“战争爆炸”(通过“部署”)
  2. 在“服务器”选项卡上,设置“在框架停用”到“更新类和资源”

按顺序执行这两个步骤将导致当 IDEA 失去焦点时(即当您将焦点更改到 Web 浏览器时)项目被“热交换”。

完整说明位于 http://www.jetbrains.com/help/idea/2016.1/updating-applications-on-application-servers.html?search=application%20servers

As I answer this question, IntelliJ IDEA is at version 13.0.2. The options are slightly different since this question was asked. In short, via the "Run/Debug Configurations" panel for your project:

  1. Make sure your project is set to be deployed as "war exploded" (via the "Deployment")
  2. On the "Server" tab, set "On frame deactivation" to "Update classes and resources"

Following those two steps, in order, will result in the project being "hot swapped" when IDEA loses focus (i.e. when you change focus to a web browser).

The full instructions are available at http://www.jetbrains.com/help/idea/2016.1/updating-applications-on-application-servers.html?search=application%20servers

南笙 2024-11-06 13:02:14

我正在使用 Intellij IDEA 10.0.3 并遇到了同样的问题。我通过检查“运行/调试配置”部分下的 tomcat 服务器设置中的“更新框架停用时的资源”设置来解决此问题。希望这有帮助。

I am using Intellij IDEA 10.0.3 and ran into the same issue. I resolved it by checking a setting - "Update resources on frame deactivation" in you tomcat server setting under the Run/Debug Configuration section. Hope this helps.

深巷少女 2024-11-06 13:02:14

尝试编辑运行/调试配置,转到“部署”选项卡并部署分解的 war 文件。

Try to edit Run/Debug Configuration, go to Deployment tab and deploy exploded war file.

永不分离 2024-11-06 13:02:14

几年前,我将 Tomcat 配置为在看到修改时间发生变化时重新编译 jsp。最近我尝试了相同的设置,但它对我不起作用。

在我的情况下,我需要看到的更改主要是 html 中的更改,因此我能够将大部分 html 封装到一个单独的 html 文件中。然后,我使用读取的文件将其内容包含在 jsp 中。然后,我能够立即更改浏览器中反映的 html,而无需重新部署。请注意,jsp include 并没有做到这一点(它缓存了 html),必须使用 java 帮助程序中的文件读取器来读取文件,以将字符串返回到 jsp。 (您可以将java逻辑放在jsp中,但这根本不像mvc)

这种方法的一个警告是将变量数据合并到读取的html文件中。您可以使用多种方法。 1. 编写您自己的字符串替换算法,并让您的帮助应用程序动态替换字符串 2. 将您的变量数据输出到 javascript 块中,并让 javascript 更新您的文件读取 html 块中的 html 值(假设您有需要提取的 javascript 块)关闭)。

Years ago I had Tomcat configured to recompile jsp's when it saw a change in the modified time. Recently I tried the same settings, but it did not work for me.

In my situation the changes I needed to see were mostly changes in html and so I was able to encapsulate most of the html into a separate html file. I then include its contents within the jsp using a file read. I was then able to get immediate changes to the html reflected in the browser without a redeploy. Note that a jsp include did not do the trick (it cached the html), had to read the file using a file reader within a java helper to return the string to the jsp. (you could put the java logic in the jsp, but that's not at all mvc-like)

One caveat to this approach is merging variable data into the file read html. There are a couple of approaches you can use. 1. make up your own string replace algorithm and have your helper app dynamically replace the strings 2. output your variable data into a javascript block and let javascript update the html values within your file read html block (assuming you have the javascript chops to pull that off).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文