Tomcat:如何覆盖web.xml servlet init-param

时间:2017-01-13 09:34:07

标签: java tomcat servlets configuration war

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

使用 Tomcat 7 ,有没有办法覆盖其中一些参数

(旁边更改战争文件中提取的web.xml

1 个答案:

答案 0 :(得分:-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.