为什么我的 JSP 更改不重启 Tomcat 就没有反映? [英] Why are my JSP changes are not reflected without restarting Tomcat?
问题描述
我正在编辑直接驻留在 tomcat/webapps/myapp/WEB-INF
中的 JSP 文件,但要查看更改,我必须重新启动服务器.据我所知,JSP 更改不需要您重新启动服务器.我发现与自动重新加载相关的唯一配置是 reloadable = "true"
I am editing JSP files which are residing directly inside tomcat/webapps/myapp/WEB-INF
, but to see the changes, I have to restart the server. As far as I know, JSP changes don't require you to restart the server. The only configuration I found which is related to automatic reloading is reloadable = "true"
如果你想让 Catalina 设置为 true监视/WEB-INF/classes/中的类和/WEB-INF/lib 用于更改,以及自动重新加载网页如果检测到更改,则应用程序.
Set to true if you want Catalina to monitor classes in /WEB-INF/classes/ and /WEB-INF/lib for changes, and automatically reload the web application if a change is detected.
我在 context.xml
中使用了这个属性,但问题仍然存在.没有重新启动就无法检测到 JSP 文件更改的其他可能原因是什么?
I used this attribute in the context.xml
, but still the problem persists. What could be the other possible reason of not detecting changes in JSP files without restarting?
@Bozho:这是web.xml
的摘录.我需要改变什么吗?
@Bozho:
This is the excerpt from web.xml
. Do I need to change something?
<servlet>
<servlet-name>jsp</servlet-name>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<init-param>
<param-name>fork</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>xpoweredBy</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
推荐答案
在 tomcat 文档 中,查看 development
设置.必须将其设置为 true 才能重新加载 jsps.
In the tomcat docs, see the development
setting. It must be set to true in order to have jsps reloaded.
development - Jasper 是否用于开发模式?如果为 true,则可以通过 modifyTestInterval 参数指定检查 JSP 修改的频率.true 或 false,默认为 true.
development - Is Jasper used in development mode? If true, the frequency at which JSPs are checked for modification may be specified via the modificationTestInterval parameter.true or false, default true.
这是在你的CATALINA_HOME/conf/web.xml
另外,如果你需要在生产环境不重启刷新一个jsp,可以到CATALINA_HOME/work/Catalina/localhost/contentName/org/apache/jsp
删除your_jsp.java
和 your_jsp.class
文件.它们将在下次访问时重新创建.
Additionally, if you need to refresh a jsp in a production environment without restart, you can go to CATALINA_HOME/work/Catalina/localhost/contentName/org/apache/jsp
and delete the your_jsp.java
and your_jsp.class
files. They will be recreated the next time they are accessed.
在提供您的配置并评论不刷新内容后,我还有另一个:清除浏览器缓存,或从其他浏览器打开页面.
after providing your configuration, and comment about not refreshing the content, I have another though: clear your browser cache, or open the page from another browser.
这篇关于为什么我的 JSP 更改不重启 Tomcat 就没有反映?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!