.xhtml文件中的更改未反映在浏览器中,需要重新启动和构建 [英] Changes in .xhtml file not reflected in browser, restart and build needed
问题描述
如果我在.xhtml
文件中进行了更改,则这些更改不会反映在浏览器的屏幕上.为了使其正常工作,我必须每次都重新启动服务器.在我看来这很笨拙.
If I make changes in my .xhtml
file, the changes are not getting reflected on the screen in my browser. To get it to work, I have to restart the server everytime. This seems unwieldy to me.
我在web.xml
中添加了以下上下文参数:
I have added the following context parameters in my web.xml
:
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
<param-value>1</param-value>
</context-param>
但是,它们没有任何作用.
However, they did not have any effect.
下面列出了我的技术堆栈:
My technology stack is listed below:
- SWF 2.3.0
- Primefaces 2.2.1
- JSF 2
- Spring Security 3
- 春季3.1.0M1I
- EhCache
- Apache Tomcat 6.0
- STS 2.5.1.
推荐答案
如果使用的是IDE,则还必须配置IDE才能立即将更改发布到服务器.否则,在服务器上运行的Web应用程序将不会获得这些更改的任何信息.
If you're using an IDE, then you have to configure your IDE as well to publish changes to the server immediately. Otherwise the webapp which is running on the server won't get any notion of those changes.
当您使用的STS基本上是Eclipse for Java EE时,预装了许多Spring特定的插件,我认为给出以Eclipse为目标的通用答案是绰绰有余的.
As you're using STS which in turn is basically Eclipse for Java EE which is preloaded with a bunch of Spring specific plugins, I think that giving a generic Eclipse-targeted answer is more than sufficient.
在Eclipse中,您只需在 Servers 视图中双击服务器条目,然后编辑 Publishing 部分以将设置为在资源更改时自动发布并设置尽可能短的发布间隔.甚至可能是 0 秒.
In Eclipse, you just have to doubleclick the server entry in Servers view and then edit the Publishing section to set Automatically publish when resources changes and set the publishing interval as low as possible. It can even be 0 seconds.
javax.faces.FACELETS_REFRESH_PERIOD
仅适用于webapp上下文中的文件.您只需要确保IDE尽快将更改发布到webapp上下文中即可.
That javax.faces.FACELETS_REFRESH_PERIOD
only applies on the files in the webapp context. You just have to make sure that the IDE is publishing changes to the webapp context as soon as possible.
这篇关于.xhtml文件中的更改未反映在浏览器中,需要重新启动和构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!