java 程序 参数,如何为Java Web应用程序设置参数

I have a web app in Java, which uses some external program (invokes a command line tool).

I want to make the path of the command line program configurable, so that I can change it without re-building my application.

Questions:

1) Which exactly parameter should I use (out of those available in web.xml), if it is set only once (at deployment) and thereafter never changes?

2) How can I access this parameter inside my Java code?

Thanks in advance

Dmitri

解决方案

web.xml

command

SOME_COMMAND

.

.

.

.

Java code

String commandToExecute = getServletContext().getInitParameter("command");

Alternatively

You can also put this thing in property/xml file in the classpath read it and put it to servlet context when context initializes.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值