显示“上下文初始化失败”后的设置
我现在正在寻找以下问题的答案几天:
我有一个 Spring 2.5 Web 应用程序,如果 spring 上下文的初始化失败,我想显示某个设置屏幕。在此设置屏幕中,他们可以查看服务器未启动的原因,并可能进行一些更改(上传新的 config.properties 文件),
但是我如何以智能方式实现此操作? Spring 是否已经有了类似的东西,或者我是否需要扩展 ContextLoader?
我在 web.xml 中尝试了如下操作:但这似乎不起作用:
<error-page>
<error-code>404</error-code>
<location>/public/setup.jsp</location>
</error-page>
解决方案:
我从默认的 web.xml 开始,设置完成后,我将 web.xml 替换为正确的“应用程序”web.xml。由于 web.xml 被替换,服务器将重新启动。这很好用。再次感谢您的回答。
I'm looking now for a couple of days for the answer to the following question:
I have a Spring 2.5
webapplication and I want to show a certain setup screen if the initialization of the spring context has failed. In this setup screen they can look why the server doesn't startup and maybe make some changes (upload new config.properties
file)
But how can I implemented this on a smart way? Has Spring already something like this or do I need to extend the ContextLoader
for example?
I tried something in the web.xml like this: but this doesn't seems to work:
<error-page>
<error-code>404</error-code>
<location>/public/setup.jsp</location>
</error-page>
Solution:
I start with a default web.xml and after the setup is done I replace the web.xml with the right 'application' web.xml. Because the web.xml is replaced the servers restarts. This works great. Thanks again for your answers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里有三个想法:
我不认为存在用于添加/删除 servlet 以及从容器映射的标准机制。但看起来大多数容器都有一些 API 可以做到这一点。
还有第三种方法,正如您所暗示的。假设如果发生 404 错误,则 servlet 无法启动。如果你沿着这条路线走下去,我想你会遇到 404 错误可能发生的问题,因为用户粗暴地手指了 URL。
Here are three ideas:
I don't think there are standard mechanisms for adding/removing servlets and mapping from the container. But it looks like most containers have some APIs that do this.
There is a third way, which you were hinting. Which is to assume that if a 404 error occured then servlet failed to start. If you go down that route I think you will run into the issue that 404 errors can occurs just because the user fat fingered the url.