【问题标题】:Tomcat: How to override web.xml servlet init-paramTomcat:如何覆盖 web.xml servlet init-param
【发布时间】:2017-01-13 09:34:07
【问题描述】:

想象一个您无法更改的战争文件。 .war 文件的 web.xml 使用一组 init-param 元素定义 servlet(not:servlet 上下文参数)。

使用 Tomcat 7,有没有办法覆盖其中一些参数?
(除了更改从战争文件中提取的web.xml)

【问题讨论】:

  • tomcat的conf/web.xml,可以查看tomcat.apache.org/tomcat-4.1-doc/config/context.html这个链接和主题Automatic Context Configuration。
  • @TahirHussainMir 这个网址没有说明 servlet init-param。您可能会将它们与 servlet 上下文参数混淆。

标签: java tomcat servlets configuration war


【解决方案1】:
It's called init-parameter for a reason. So, you can't.

But you can change values at runtime, that's no problem.

After reading the init parameters put them as attributes of the ServletContext (ctx.setAttribute("name", value))
Create a small (password-protected) page that lists all attributes of the ServletContext and gives the ability to change them.

【讨论】:

  • 作为一个小评论:许多其他应用服务器允许覆盖这些值。
  • 已经说不能修改.war了,那你要怎么加个程序来做呢?
猜你喜欢
  • 2012-01-30
  • 2014-12-05
  • 2017-05-04
  • 1970-01-01
  • 2012-09-23
  • 2017-08-19
  • 2013-03-01
  • 1970-01-01
  • 2011-11-24
相关资源
最近更新 更多